// src/translations.js

// Helper function for simple variable replacement (e.g., {name})
// Handles only one level deep, no complex formatting.
const simpleInterpolate = (str, variables) => {
    if (!variables) return str;
    return str.replace(/\{(\w+)\}/g, (match, key) => {
        return variables.hasOwnProperty(key) ? variables[key] : match;
    });
};

// --- English Translations (Default) ---
const en = {
    selkiesLogoAlt: "Selkies Logo",
    toggleThemeTitle: "Toggle Theme",
    fullscreenTitle: "Enter Fullscreen",
    gamingModeTitle: "Gaming Mode",
    trackpadModeTitle: "Trackpad Mode",
    buttons: {
        videoStreamEnableTitle: "Enable Video Stream",
        videoStreamDisableTitle: "Disable Video Stream",
        audioStreamEnableTitle: "Enable Audio Stream",
        audioStreamDisableTitle: "Disable Audio Stream",
        microphoneEnableTitle: "Enable Microphone",
        microphoneDisableTitle: "Disable Microphone",
        gamepadEnableTitle: "Enable Gamepad Input",
        gamepadDisableTitle: "Disable Gamepad Input",
        virtualKeyboardButtonTitle: "Pop Keyboard",
        h264FullColorEnableTitle: "Enable H.264 Full Color",
        h264FullColorDisableTitle: "Disable H.264 Full Color",
        h264StreamingModeDisableTitle: "Disable Turbo",
        h264StreamingModeEnableTitle: "Enable Turbo",
        useCpuEnableTitle: "Enable Force CPU Encoding (Overrides nvenc/vaapi)",
        useCpuDisableTitle: "Disable Force CPU Encoding (Overrides nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Enable Paint-Overs (Cleans up static portions of the screen)",
        usePaintOverQualityDisableTitle: "Disable Paint-Overs (Cleans up static portions of the screen)",
        binaryClipboardEnableTitle: "Enable Image Clipboard",
        binaryClipboardDisableTitle: "Disable Image Clipboard",
    },
    sections: {
        video: {
            title: "Video Settings",
            encoderLabel: "Encoder:",
            framerateLabel: "Frames per second ({framerate} FPS):",
            bitrateLabel: "Video Bitrate ({bitrate} Mbps):",
            bufferLabelImmediate: "Video Buffer Size (0 (Immediate)):",
            bufferLabelFrames: "Video Buffer Size ({videoBufferSize} frames):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "FullColor 4:4:4",
            streamingModeDetails: "Turbo mode disables all VNC logic and encodes all frames like a traditional video encoder.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU Encoding",
            jpegQualityLabel: "Base Quality: {jpegQuality}",
            paintOverJpegQualityLabel: "Paintover Quality: {paintOverJpegQuality}",
            paintoverCrfLabel: "Paint-Overs CRF ({crf}):",
            usePaintOverQualityLabel: "Use Paint-Overs",
        },
        audio: {
            title: "Audio Settings",
            bitrateLabel: "Audio Bitrate ({bitrate} kbps):",
            inputLabel: "Input (Microphone):",
            outputLabel: "Output (Speaker):",
            outputNotSupported: "Output device selection not supported by this browser.",
            deviceErrorDefault: "Error listing audio devices: {errorName}",
            deviceErrorPermission: "Permission denied. Please allow microphone access in browser settings to select devices.",
            deviceErrorNotFound: "No audio devices found.",
            defaultInputLabelFallback: "Input Device {index}",
            defaultOutputLabelFallback: "Output Device {index}",
        },
        screen: {
            title: "Screen Settings",
            presetLabel: "Preset:",
            resolutionPresetSelect: "-- Select Preset --",
            widthLabel: "Width:",
            heightLabel: "Height:",
            widthPlaceholder: "e.g., 1920",
            heightPlaceholder: "e.g., 1080",
            setManualButton: "Set Manual Resolution",
            resetButton: "Reset to Window",
            scaleLocallyLabel: "Scale Locally:",
            scaleLocallyOn: "ON",
            scaleLocallyOff: "OFF",
            scaleLocallyTitleEnable: "Enable Local Scaling (Maintain Aspect Ratio)",
            scaleLocallyTitleDisable: "Disable Local Scaling (Use Exact Resolution)",
            uiScalingLabel: "UI Scaling",
            hidpiLabel: "HiDPI (Pixel Perfect)",
            hidpiEnableTitle: "Enable HiDPI (Pixel Perfect)",
            hidpiDisableTitle: "Disable HiDPI (Use CSS Scaling)",
            antiAliasingLabel: "Anti-aliasing",
            antiAliasingEnableTitle: "Enable anti-aliasing (smooth on scaling)",
            antiAliasingDisableTitle: "Disable anti-aliasing (force pixelated)",
            useNativeCursorStylesLabel: "Use CSS cursors",
            useNativeCursorStylesEnableTitle: "Use CSS cursor rendering (Replace system cursors)",
            useNativeCursorStylesDisableTitle: "Use canvas cursor rendering (Paint to canvas)",
            addScreenTitle: "Add a second screen",
            addScreenButton: "Add Screen +",
        },
        stats: {
            title: "Stats",
            cpuLabel: "CPU",
            gpuLabel: "GPU Usage",
            sysMemLabel: "Sys Mem",
            gpuMemLabel: "GPU Mem",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "CPU Usage: {value}%",
            tooltipGpu: "GPU Usage: {value}%",
            tooltipSysMem: "System Memory: {used} / {total}",
            tooltipGpuMem: "GPU Memory: {used} / {total}",
            tooltipFps: "Client FPS: {value}",
            tooltipAudio: "Audio Buffers: {value}",
            tooltipMemoryNA: "N/A",
            bandwidthLabel: "Bandwidth",
            tooltipBandwidth: "Bandwidth: {value}mbps",
            latencyLabel: "Latency",
            tooltipLatency: "Round Trip Latency: {value}ms",
        },
        clipboard: {
            title: "Clipboard",
            label: "Server Clipboard:",
            placeholder: "Clipboard content from server...",
            binaryModeLabel: "Image Support",
            binaryModeDetails: "Allows copying and pasting images to and from the remote session.",
        },
        files: {
            title: "Files",
            uploadButton: "Upload Files",
            uploadButtonTitle: "Upload files to the remote session",
            downloadButtonTitle: "Download Files",
        },
        gamepads: {
            title: "Gamepads",
            noActivity: "No physical gamepad activity detected yet...",
            touchEnableTitle: "Enable Touch Gamepad",
            touchDisableTitle: "Disable Touch Gamepad",
            touchActiveLabel: "Touch Gamepad: ON",
            touchInactiveLabel: "Touch Gamepad: OFF",
            physicalHiddenForTouch: "Physical gamepad display is hidden while touch gamepad is active.",
            noActivityMobileOrEnableTouch: "No physical gamepads. Enable touch gamepad or connect a controller."
        },
        apps: {
          title: "Apps",
          openButtonTitle: "Manage Apps",
          openButton: "Manage Apps"
        },
        sharing: {
            title: "Sharing"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { 
        closeAlt: "Close apps modal",
        loading: "Loading apps...",
        errorLoading: "Failed to load app data. Please try again.",
        searchPlaceholder: "Search apps...",
        noAppsFound: "No apps found matching your search.",
        backButton: "Back to list",
        installButton: "Install",
        updateButton: "Update",
        removeButton: "Remove",
        installingMessage: "Simulating install for: {{appName}}",
        removingMessage: "Simulating removal for: {{appName}}",
        updatingMessage: "Simulating update for: {{appName}}",
        installedBadge: "Installed"
    },
    notifications: {
        closeButtonAlt: "Close notification for {fileName}",
        uploading: "Uploading... {progress}%",
        uploadComplete: "Upload Complete",
        uploadFailed: "Upload Failed",
        errorPrefix: "Error:",
        unknownError: "An unknown error occurred.",
        copiedTitle: "Copied: {label}",
        copiedMessage: "Link copied to clipboard: {textToCopy}",
        copyFailedTitle: "Copy Failed: {label}",
        copyFailedError: "Could not copy link to clipboard.",
        scalingTitle: "Scaling Updated: Action Required",
        scalingMessage: "New scaling applied. Some applications or desktop environments might require a restart.",
    },
    alerts: {
        invalidResolution: "Please enter valid positive integers for Width and Height.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Close files modal",
        iframeTitle: "Downloadable Files"
    }
};

// --- Spanish Translations (Complete) ---
const es = {
    selkiesLogoAlt: "Logo de Selkies",
    toggleThemeTitle: "Cambiar Tema",
    fullscreenTitle: "Entrar en Pantalla Completa",
    gamingModeTitle: "Modo Juego",
    trackpadModeTitle: "Modo Trackpad",
    buttons: {
        videoStreamEnableTitle: "Activar Stream de Vídeo",
        videoStreamDisableTitle: "Desactivar Stream de Vídeo",
        audioStreamEnableTitle: "Activar Stream de Audio",
        audioStreamDisableTitle: "Desactivar Stream de Audio",
        microphoneEnableTitle: "Activar Micrófono",
        microphoneDisableTitle: "Desactivar Micrófono",
        gamepadEnableTitle: "Activar Entrada de Mando",
        gamepadDisableTitle: "Desactivar Entrada de Mando",
        virtualKeyboardButtonTitle: "Mostrar Teclado",
        h264FullColorEnableTitle: "Activar H.264 Color Completo",
        h264FullColorDisableTitle: "Desactivar H.264 Color Completo",
        h264StreamingModeDisableTitle: "Desactivar Turbo",
        h264StreamingModeEnableTitle: "Activar Turbo",
        useCpuEnableTitle: "Activar Codificación Forzada por CPU (Sobrescribe nvenc/vaapi)",
        useCpuDisableTitle: "Desactivar Codificación Forzada por CPU (Sobrescribe nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Activar Mejora de Estáticos (Limpia porciones estáticas de la pantalla)",
        usePaintOverQualityDisableTitle: "Desactivar Mejora de Estáticos (Limpia porciones estáticas de la pantalla)",
        binaryClipboardEnableTitle: "Activar Portapapeles de Imágenes",
        binaryClipboardDisableTitle: "Desactivar Portapapeles de Imágenes",
    },
    sections: {
        video: {
            title: "Configuración de Vídeo",
            encoderLabel: "Codificador:",
            framerateLabel: "Fotogramas por segundo ({framerate} FPS):",
            bitrateLabel: "Tasa de bits de vídeo ({bitrate} Mbps):",
            bufferLabelImmediate: "Tamaño del Búfer de Vídeo (0 (Inmediato)):",
            bufferLabelFrames: "Tamaño del Búfer de Vídeo ({videoBufferSize} fotogramas):",
            crfLabel: "CRF de Vídeo ({crf}):",
            fullColorLabel: "Color Completo 4:4:4",
            streamingModeDetails: "El modo Turbo desactiva toda la lógica VNC y codifica todos los fotogramas como un codificador de vídeo tradicional.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "Codificación por CPU",
            jpegQualityLabel: "Calidad Base: {jpegQuality}",
            paintOverJpegQualityLabel: "Calidad de Sobrepintado: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF de Mejora de Estáticos ({crf}):",
            usePaintOverQualityLabel: "Usar Mejora de Estáticos",
        },
        audio: {
             title: "Configuración de Audio",
             bitrateLabel: "Tasa de bits de audio ({bitrate} kbps):",
             inputLabel: "Entrada (Micrófono):",
             outputLabel: "Salida (Altavoz):",
             outputNotSupported: "La selección de dispositivo de salida no es compatible con este navegador.",
             deviceErrorDefault: "Error al listar dispositivos de audio: {errorName}",
             deviceErrorPermission: "Permiso denegado. Permita el acceso al micrófono en la configuración del navegador para seleccionar dispositivos.",
             deviceErrorNotFound: "No se encontraron dispositivos de audio.",
             defaultInputLabelFallback: "Dispositivo de Entrada {index}",
             defaultOutputLabelFallback: "Dispositivo de Salida {index}",
        },
        screen: {
             title: "Configuración de Pantalla",
             presetLabel: "Preajuste:",
             resolutionPresetSelect: "-- Seleccionar Preajuste --",
             widthLabel: "Ancho:",
             heightLabel: "Alto:",
             widthPlaceholder: "ej., 1920",
             heightPlaceholder: "ej., 1080",
             setManualButton: "Establecer Resolución Manual",
             resetButton: "Restablecer a Ventana",
             scaleLocallyLabel: "Escalar Localmente:",
             scaleLocallyOn: "SÍ",
             scaleLocallyOff: "NO",
             scaleLocallyTitleEnable: "Activar Escalado Local (Mantener Relación de Aspecto)",
             scaleLocallyTitleDisable: "Desactivar Escalado Local (Usar Resolución Exacta)",
             uiScalingLabel: "Escalado de Interfaz:",
             hidpiLabel: "HiDPI (Píxel Perfecto)",
             hidpiEnableTitle: "Activar HiDPI (Píxel Perfecto)",
             hidpiDisableTitle: "Desactivar HiDPI (Usar escalado CSS)",
             antiAliasingLabel: "Anti-aliasing",
             antiAliasingEnableTitle: "Activar anti-aliasing (suavizar al escalar)",
             antiAliasingDisableTitle: "Desactivar anti-aliasing (forzar pixelado)",
             useNativeCursorStylesLabel: "Usar cursores CSS",
             useNativeCursorStylesEnableTitle: "Usar renderizado de cursor CSS (Reemplaza los cursores del sistema)",
             useNativeCursorStylesDisableTitle: "Usar renderizado de cursor en lienzo (Pintar en el lienzo)",
             addScreenTitle: "Añadir una segunda pantalla",
             addScreenButton: "Añadir Pantalla +",
        },
        stats: {
             title: "Estadísticas",
             cpuLabel: "CPU",
             gpuLabel: "Uso de GPU",
             sysMemLabel: "Mem Sistema",
             gpuMemLabel: "Mem GPU",
             fpsLabel: "FPS",
             audioLabel: "Audio",
             tooltipCpu: "Uso de CPU: {value}%",
             tooltipGpu: "Uso de GPU: {value}%",
             tooltipSysMem: "Memoria del Sistema: {used} / {total}",
             tooltipGpuMem: "Memoria GPU: {used} / {total}",
             tooltipFps: "FPS del Cliente: {value}",
             tooltipAudio: "Búferes de Audio: {value}",
             tooltipMemoryNA: "N/D",
             bandwidthLabel: "Ancho de Banda",
             tooltipBandwidth: "Ancho de Banda: {value}mbps",
             latencyLabel: "Latencia",
             tooltipLatency: "Latencia de Ida y Vuelta: {value}ms",
        },
        clipboard: {
             title: "Portapapeles",
             label: "Portapapeles del Servidor:",
             placeholder: "Contenido del portapapeles del servidor...",
             binaryModeLabel: "Soporte de Imágenes",
             binaryModeDetails: "Permite copiar y pegar imágenes desde y hacia la sesión remota.",
        },
        files: {
             title: "Archivos",
             uploadButton: "Subir Archivos",
             uploadButtonTitle: "Subir archivos a la sesión remota",
             downloadButtonTitle: "Descargar Archivos",
        },
        gamepads: {
             title: "Mandos",
             noActivity: "Aún no se ha detectado actividad del mando...",
             touchEnableTitle: "Activar Mando Táctil",
             touchDisableTitle: "Desactivar Mando Táctil",
             touchActiveLabel: "Mando Táctil: ENCENDIDO",
             touchInactiveLabel: "Mando Táctil: APAGADO",
             physicalHiddenForTouch: "La visualización de mandos físicos está oculta mientras el mando táctil está activo.",
             noActivityMobileOrEnableTouch: "No hay mandos físicos. Active el mando táctil o conecte un controlador."
        },
        apps: { 
          title: "Aplicaciones",
          openButtonTitle: "Gestionar Aplicaciones",
          openButton: "Gestionar Aplicaciones"
        },
        sharing: {
            title: "Compartir"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Portátil)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Cerrar modal de aplicaciones",
        loading: "Cargando aplicaciones...",
        errorLoading: "Error al cargar los datos de las aplicaciones. Por favor, inténtalo de nuevo.",
        searchPlaceholder: "Buscar aplicaciones...",
        noAppsFound: "No se encontraron aplicaciones que coincidan con tu búsqueda.",
        backButton: "Volver a la lista",
        installButton: "Instalar",
        updateButton: "Actualizar",
        removeButton: "Eliminar",
        installingMessage: "Simulando instalación para: {{appName}}",
        removingMessage: "Simulando eliminación para: {{appName}}",
        updatingMessage: "Simulando actualización para: {{appName}}",
        installedBadge: "Instalado"
    },
    notifications: {
        closeButtonAlt: "Cerrar notificación para {fileName}",
        uploading: "Subiendo... {progress}%",
        uploadComplete: "Subida Completa",
        uploadFailed: "Subida Fallida",
        errorPrefix: "Error:",
        unknownError: "Ocurrió un error desconocido.",
        copiedTitle: "Copiado: {label}",
        copiedMessage: "Enlace copiado al portapapeles: {textToCopy}",
        copyFailedTitle: "Error al Copiar: {label}",
        copyFailedError: "No se pudo copiar el enlace al portapapeles.",
        scalingTitle: "Escalado Actualizado: Acción Requerida",
        scalingMessage: "Nuevo escalado aplicado. Algunas aplicaciones o entornos de escritorio pueden requerir un reinicio.",
    },
    alerts: {
        invalidResolution: "Por favor, introduzca números enteros positivos válidos para Ancho y Alto.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Cerrar modal de archivos",
        iframeTitle: "Archivos Descargables"
    }
};

// --- Chinese (Simplified) Translations ---
const zh = {
    selkiesLogoAlt: "Selkies 徽标",
    toggleThemeTitle: "切换主题",
    fullscreenTitle: "进入全屏",
    gamingModeTitle: "游戏模式",
    trackpadModeTitle: "触控板模式",
    buttons: {
        videoStreamEnableTitle: "启用视频流",
        videoStreamDisableTitle: "禁用视频流",
        audioStreamEnableTitle: "启用音频流",
        audioStreamDisableTitle: "禁用音频流",
        microphoneEnableTitle: "启用麦克风",
        microphoneDisableTitle: "禁用麦克风",
        gamepadEnableTitle: "启用游戏手柄输入",
        gamepadDisableTitle: "禁用游戏手柄输入",
        virtualKeyboardButtonTitle: "弹出键盘",
        h264FullColorEnableTitle: "启用 H.264 全彩",
        h264FullColorDisableTitle: "禁用 H.264 全彩",
        h264StreamingModeDisableTitle: "禁用 Turbo",
        h264StreamingModeEnableTitle: "启用 Turbo",
        useCpuEnableTitle: "启用强制 CPU 编码 (覆盖 nvenc/vaapi)",
        useCpuDisableTitle: "禁用强制 CPU 编码 (覆盖 nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "启用静态区域优化 (清理屏幕的静态部分)",
        usePaintOverQualityDisableTitle: "禁用静态区域优化 (清理屏幕的静态部分)",
        binaryClipboardEnableTitle: "启用图像剪贴板",
        binaryClipboardDisableTitle: "禁用图像剪贴板",
    },
    sections: {
        video: {
            title: "视频设置",
            encoderLabel: "编码器:",
            framerateLabel: "帧率 ({framerate} FPS):",
            bitrateLabel: "视频比特率 ({bitrate} Mbps):",
            bufferLabelImmediate: "视频缓冲大小 (0 (立即)):",
            bufferLabelFrames: "视频缓冲大小 ({videoBufferSize} 帧):",
            crfLabel: "视频 CRF ({crf}):",
            fullColorLabel: "全彩 4:4:4",
            streamingModeDetails: "Turbo 模式会禁用所有 VNC 逻辑，并像传统视频编码器一样对所有帧进行编码。",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU 编码",
            jpegQualityLabel: "基础质量: {jpegQuality}",
            paintOverJpegQualityLabel: "覆盖图质量: {paintOverJpegQuality}",
            paintoverCrfLabel: "静态区域优化 CRF ({crf}):",
            usePaintOverQualityLabel: "使用静态区域优化",
        },
        audio: {
            title: "音频设置",
            bitrateLabel: "音频比特率 ({bitrate} kbps):",
            inputLabel: "输入 (麦克风):",
            outputLabel: "输出 (扬声器):",
            outputNotSupported: "此浏览器不支持输出设备选择。",
            deviceErrorDefault: "列出音频设备时出错: {errorName}",
            deviceErrorPermission: "权限被拒绝。请在浏览器设置中允许麦克风访问以选择设备。",
            deviceErrorNotFound: "未找到音频设备。",
            defaultInputLabelFallback: "输入设备 {index}",
            defaultOutputLabelFallback: "输出设备 {index}",
        },
        screen: {
            title: "屏幕设置",
            presetLabel: "预设:",
            resolutionPresetSelect: "-- 选择预设 --",
            widthLabel: "宽度:",
            heightLabel: "高度:",
            widthPlaceholder: "例如 1920",
            heightPlaceholder: "例如 1080",
            setManualButton: "设置手动分辨率",
            resetButton: "重置为窗口大小",
            scaleLocallyLabel: "本地缩放:",
            scaleLocallyOn: "开",
            scaleLocallyOff: "关",
            scaleLocallyTitleEnable: "启用本地缩放 (保持宽高比)",
            scaleLocallyTitleDisable: "禁用本地缩放 (使用精确分辨率)",
            uiScalingLabel: "界面缩放:",
            hidpiLabel: "HiDPI (像素完美)",
            hidpiEnableTitle: "启用 HiDPI (像素完美)",
            hidpiDisableTitle: "禁用 HiDPI (使用 CSS 缩放)",
            antiAliasingLabel: "抗锯齿",
            antiAliasingEnableTitle: "启用抗锯齿 (缩放时平滑)",
            antiAliasingDisableTitle: "禁用抗锯齿 (强制像素化)",
            useNativeCursorStylesLabel: "使用 CSS 光标",
            useNativeCursorStylesEnableTitle: "使用 CSS 光标渲染 (替换系统光标)",
            useNativeCursorStylesDisableTitle: "使用画布光标渲染 (绘制到画布)",
            addScreenTitle: "添加第二个屏幕",
            addScreenButton: "添加屏幕 +",
        },
        stats: {
            title: "统计信息",
            cpuLabel: "CPU",
            gpuLabel: "GPU 使用率",
            sysMemLabel: "系统内存",
            gpuMemLabel: "GPU 内存",
            fpsLabel: "FPS",
            audioLabel: "音频",
            tooltipCpu: "CPU 使用率: {value}%",
            tooltipGpu: "GPU 使用率: {value}%",
            tooltipSysMem: "系统内存: {used} / {total}",
            tooltipGpuMem: "GPU 内存: {used} / {total}",
            tooltipFps: "客户端 FPS: {value}",
            tooltipAudio: "音频缓冲区: {value}",
            tooltipMemoryNA: "不可用",
            bandwidthLabel: "带宽",
            tooltipBandwidth: "带宽: {value}mbps",
            latencyLabel: "延迟",
            tooltipLatency: "往返延迟: {value}ms",
        },
        clipboard: {
            title: "剪贴板",
            label: "服务器剪贴板:",
            placeholder: "来自服务器的剪贴板内容...",
            binaryModeLabel: "图像支持",
            binaryModeDetails: "允许在远程会话中复制和粘贴图像。",
        },
        files: {
            title: "文件",
            uploadButton: "上传文件",
            uploadButtonTitle: "上传文件到远程会话",
            downloadButtonTitle: "下载文件",
        },
        gamepads: {
            title: "游戏手柄",
            noActivity: "尚未检测到游戏手柄活动...",
            touchEnableTitle: "启用触摸手柄",
            touchDisableTitle: "禁用触摸手柄",
            touchActiveLabel: "触摸手柄: 开",
            touchInactiveLabel: "触摸手柄: 关",
            physicalHiddenForTouch: "触摸手柄激活时，物理手柄显示将被隐藏。",
            noActivityMobileOrEnableTouch: "没有物理手柄。请启用触摸手柄或连接控制器。"
        },
        apps: { 
          title: "应用程序",
          openButtonTitle: "管理应用程序",
          openButton: "管理应用程序"
        },
        sharing: {
            title: "共享"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (笔记本)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "关闭应用程序模态框",
        loading: "正在加载应用程序...",
        errorLoading: "加载应用程序数据失败。请重试。",
        searchPlaceholder: "搜索应用程序...",
        noAppsFound: "未找到与您的搜索匹配的应用程序。",
        backButton: "返回列表",
        installButton: "安装",
        updateButton: "更新",
        removeButton: "移除",
        installingMessage: "模拟安装: {{appName}}",
        removingMessage: "模拟移除: {{appName}}",
        updatingMessage: "模拟更新: {{appName}}",
        installedBadge: "已安装"
    },
    notifications: {
        closeButtonAlt: "关闭 {fileName} 的通知",
        uploading: "正在上传... {progress}%",
        uploadComplete: "上传完成",
        uploadFailed: "上传失败",
        errorPrefix: "错误:",
        unknownError: "发生未知错误。",
        copiedTitle: "已复制: {label}",
        copiedMessage: "链接已复制到剪贴板: {textToCopy}",
        copyFailedTitle: "复制失败: {label}",
        copyFailedError: "无法将链接复制到剪贴板。",
        scalingTitle: "缩放已更新：需要操作",
        scalingMessage: "新的缩放已应用。某些应用程序或桌面环境可能需要重启。",
    },
    alerts: {
        invalidResolution: "请输入有效的正整数作为宽度和高度。",
    },
    byteUnits: ['字节', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 字节",
    filesModal: {
        closeAlt: "关闭文件模态框",
        iframeTitle: "可下载文件"
    }
};

// --- Hindi Translations ---
const hi = {
    selkiesLogoAlt: "सेल्कीस लोगो",
    toggleThemeTitle: "थीम बदलें",
    fullscreenTitle: "फुलस्क्रीन दर्ज करें",
    gamingModeTitle: "गेमिंग मोड",
    trackpadModeTitle: "ट्रैकपैड मोड",
    buttons: {
        videoStreamEnableTitle: "वीडियो स्ट्रीम सक्षम करें",
        videoStreamDisableTitle: "वीडियो स्ट्रीम अक्षम करें",
        audioStreamEnableTitle: "ऑडियो स्ट्रीम सक्षम करें",
        audioStreamDisableTitle: "ऑडियो स्ट्रीम अक्षम करें",
        microphoneEnableTitle: "माइक्रोफ़ोन सक्षम करें",
        microphoneDisableTitle: "माइक्रोफ़ोन अक्षम करें",
        gamepadEnableTitle: "गेमपैड इनपुट सक्षम करें",
        gamepadDisableTitle: "गेमपैड इनपुट अक्षम करें",
        virtualKeyboardButtonTitle: "कीबोर्ड दिखाएँ",
        h264FullColorEnableTitle: "H.264 फुल कलर सक्षम करें",
        h264FullColorDisableTitle: "H.264 फुल कलर अक्षम करें",
        h264StreamingModeDisableTitle: "टर्बो अक्षम करें",
        h264StreamingModeEnableTitle: "टर्बो सक्षम करें",
        useCpuEnableTitle: "फोर्स सीपीयू एन्कोडिंग सक्षम करें (nvenc/vaapi को ओवरराइड करता है)",
        useCpuDisableTitle: "फोर्स सीपीयू एन्कोडिंग अक्षम करें (nvenc/vaapi को ओवरराइड करता है)",
        usePaintOverQualityEnableTitle: "स्थिर छवि सुधार सक्षम करें (स्क्रीन के स्थिर हिस्सों को साफ करता है)",
        usePaintOverQualityDisableTitle: "स्थिर छवि सुधार अक्षम करें (स्क्रीन के स्थिर हिस्सों को साफ करता है)",
        binaryClipboardEnableTitle: "छवि क्लिपबोर्ड सक्षम करें",
        binaryClipboardDisableTitle: "छवि क्लिपबोर्ड अक्षम करें",
    },
    sections: {
        video: {
            title: "वीडियो सेटिंग्स",
            encoderLabel: "एन्कोडर:",
            framerateLabel: "फ्रेम प्रति सेकंड ({framerate} FPS):",
            bitrateLabel: "वीडियो बिटरेट ({bitrate} Mbps):",
            bufferLabelImmediate: "वीडियो बफर आकार (0 (तत्काल)):",
            bufferLabelFrames: "वीडियो बफर आकार ({videoBufferSize} फ्रेम):",
            crfLabel: "वीडियो CRF ({crf}):",
            fullColorLabel: "फुल कलर 4:4:4",
            streamingModeDetails: "टर्बो मोड सभी VNC लॉजिक को अक्षम कर देता है और सभी फ्रेम को एक पारंपरिक वीडियो एन्कोडर की तरह एन्कोड करता है।",
            streamingModeLabel: "टर्बो",
            useCpuLabel: "सीपीयू एन्कोडिंग",
            jpegQualityLabel: "आधार गुणवत्ता: {jpegQuality}",
            paintOverJpegQualityLabel: "पेंटओवर गुणवत्ता: {paintOverJpegQuality}",
            paintoverCrfLabel: "स्थिर छवि सुधार CRF ({crf}):",
            usePaintOverQualityLabel: "स्थिर छवि सुधार का उपयोग करें",
        },
        audio: {
            title: "ऑडियो सेटिंग्स",
            bitrateLabel: "ऑडियो बिटरेट ({bitrate} kbps):",
            inputLabel: "इनपुट (माइक्रोफ़ोन):",
            outputLabel: "आउटपुट (स्पीकर):",
            outputNotSupported: "इस ब्राउज़र द्वारा आउटपुट डिवाइस चयन समर्थित नहीं है।",
            deviceErrorDefault: "ऑडियो डिवाइस सूचीबद्ध करने में त्रुटि: {errorName}",
            deviceErrorPermission: "अनुमति अस्वीकृत। डिवाइस चुनने के लिए कृपया ब्राउज़र सेटिंग्स में माइक्रोफ़ोन एक्सेस की अनुमति दें।",
            deviceErrorNotFound: "कोई ऑडियो डिवाइस नहीं मिला।",
            defaultInputLabelFallback: "इनपुट डिवाइस {index}",
            defaultOutputLabelFallback: "आउटपुट डिवाइस {index}",
        },
        screen: {
            title: "स्क्रीन सेटिंग्स",
            presetLabel: "प्रीसेट:",
            resolutionPresetSelect: "-- प्रीसेट चुनें --",
            widthLabel: "चौड़ाई:",
            heightLabel: "ऊंचाई:",
            widthPlaceholder: "उदा. 1920",
            heightPlaceholder: "उदा. 1080",
            setManualButton: "मैनुअल रिज़ॉल्यूशन सेट करें",
            resetButton: "विंडो पर रीसेट करें",
            scaleLocallyLabel: "स्थानीय रूप से स्केल करें:",
            scaleLocallyOn: "चालू",
            scaleLocallyOff: "बंद",
            scaleLocallyTitleEnable: "स्थानीय स्केलिंग सक्षम करें (पहलू अनुपात बनाए रखें)",
            scaleLocallyTitleDisable: "स्थानीय स्केलिंग अक्षम करें (सटीक रिज़ॉल्यूशन का उपयोग करें)",
            uiScalingLabel: "यूआई स्केलिंग:",
            hidpiLabel: "HiDPI (पिक्सेल परफेक्ट)",
            hidpiEnableTitle: "HiDPI सक्षम करें (पिक्सेल परफेक्ट)",
            hidpiDisableTitle: "HiDPI अक्षम करें (CSS स्केलिंग का उपयोग करें)",
            antiAliasingLabel: "एंटी-अलियासिंग",
            antiAliasingEnableTitle: "एंटी-अलियासिंग सक्षम करें (स्केलिंग पर स्मूथ)",
            antiAliasingDisableTitle: "एंटी-अलियासिंग अक्षम करें (पिक्सेलयुक्त करने के लिए बाध्य करें)",
            useNativeCursorStylesLabel: "CSS कर्सर का उपयोग करें",
            useNativeCursorStylesEnableTitle: "CSS कर्सर रेंडरिंग का उपयोग करें (सिस्टम कर्सर बदलें)",
            useNativeCursorStylesDisableTitle: "कैनवास कर्सर रेंडरिंग का उपयोग करें (कैनवास पर पेंट करें)",
            addScreenTitle: "एक दूसरी स्क्रीन जोड़ें",
            addScreenButton: "स्क्रीन जोड़ें +",
        },
        stats: {
            title: "आँकड़े",
            cpuLabel: "CPU",
            gpuLabel: "GPU उपयोग",
            sysMemLabel: "सिस्टम मेम",
            gpuMemLabel: "GPU मेम",
            fpsLabel: "FPS",
            audioLabel: "ऑडियो",
            tooltipCpu: "CPU उपयोग: {value}%",
            tooltipGpu: "GPU उपयोग: {value}%",
            tooltipSysMem: "सिस्टम मेमोरी: {used} / {total}",
            tooltipGpuMem: "GPU मेमोरी: {used} / {total}",
            tooltipFps: "क्लाइंट FPS: {value}",
            tooltipAudio: "ऑडियो बफ़र्स: {value}",
            tooltipMemoryNA: "लागू नहीं",
            bandwidthLabel: "बैंडविड्थ",
            tooltipBandwidth: "बैंडविड्थ: {value}mbps",
            latencyLabel: "विलंबता",
            tooltipLatency: "राउंड ट्रिप विलंबता: {value}ms",
        },
        clipboard: {
            title: "क्लिपबोर्ड",
            label: "सर्वर क्लिपबोर्ड:",
            placeholder: "सर्वर से क्लिपबोर्ड सामग्री...",
            binaryModeLabel: "छवि समर्थन",
            binaryModeDetails: "रिमोट सत्र से और उसमें छवियों को कॉपी और पेस्ट करने की अनुमति देता है।",
        },
        files: {
            title: "फ़ाइलें",
            uploadButton: "फ़ाइलें अपलोड करें",
            uploadButtonTitle: "रिमोट सेशन में फ़ाइलें अपलोड करें",
            downloadButtonTitle: "फ़ाइलें डाउनलोड करें",
        },
        gamepads: {
            title: "गेमपैड",
            noActivity: "अभी तक कोई गेमपैड गतिविधि का पता नहीं चला है...",
            touchEnableTitle: "टच गेमपैड सक्षम करें",
            touchDisableTitle: "टच गेमपैड अक्षम करें",
            touchActiveLabel: "टच गेमपैड: चालू",
            touchInactiveLabel: "टच गेमपैड: बंद",
            physicalHiddenForTouch: "टच गेमपैड सक्रिय होने पर भौतिक गेमपैड डिस्प्ले छिपा रहता है।",
            noActivityMobileOrEnableTouch: "कोई भौतिक गेमपैड नहीं। टच गेमपैड सक्षम करें या नियंत्रक कनेक्ट करें।"
        },
        apps: {
          title: "ऐप्स",
          openButtonTitle: "ऐप्स प्रबंधित करें",
          openButton: "ऐप्स प्रबंधित करें"
        },
        sharing: {
            title: "साझा करना"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (लैपटॉप)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "ऐप्स मोडल बंद करें",
        loading: "ऐप्स लोड हो रहे हैं...",
        errorLoading: "ऐप डेटा लोड करने में विफल। कृपया पुनः प्रयास करें।",
        searchPlaceholder: "ऐप्स खोजें...",
        noAppsFound: "आपकी खोज से मेल खाने वाले कोई ऐप्स नहीं मिले।",
        backButton: "सूची पर वापस जाएं",
        installButton: "इंस्टॉल करें",
        updateButton: "अपडेट करें",
        removeButton: "हटाएं",
        installingMessage: "इसके लिए इंस्टॉलेशन का अनुकरण किया जा रहा है: {{appName}}",
        removingMessage: "इसके लिए हटाने का अनुकरण किया जा रहा है: {{appName}}",
        updatingMessage: "इसके लिए अपडेट का अनुकरण किया जा रहा है: {{appName}}",
        installedBadge: "इंस्टॉल किया गया"
    },
    notifications: {
        closeButtonAlt: "{fileName} के लिए अधिसूचना बंद करें",
        uploading: "अपलोड हो रहा है... {progress}%",
        uploadComplete: "अपलोड पूर्ण",
        uploadFailed: "अपलोड विफल",
        errorPrefix: "त्रुटि:",
        unknownError: "एक अज्ञात त्रुटि हुई।",
        copiedTitle: "कॉपी किया गया: {label}",
        copiedMessage: "लिंक क्लिपबोर्ड पर कॉपी किया गया: {textToCopy}",
        copyFailedTitle: "कॉपी करने में विफल: {label}",
        copyFailedError: "लिंक क्लिपबोर्ड पर कॉपी नहीं किया जा सका।",
        scalingTitle: "स्केलिंग अपडेट किया गया: कार्रवाई आवश्यक है",
        scalingMessage: "नई स्केलिंग लागू की गई है। कुछ एप्लिकेशन या डेस्कटॉप वातावरण को पुनरारंभ करने की आवश्यकता हो सकती है।",
    },
    alerts: {
        invalidResolution: "कृपया चौड़ाई और ऊंचाई के लिए मान्य धनात्मक पूर्णांक दर्ज करें।",
    },
    byteUnits: ['बाइट्स', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 बाइट्स",
    filesModal: {
        closeAlt: "फ़ाइलें मोडल बंद करें",
        iframeTitle: "डाउनलोड करने योग्य फ़ाइलें"
    }
};

// --- Portuguese Translations ---
const pt = {
    selkiesLogoAlt: "Logo Selkies",
    toggleThemeTitle: "Alternar Tema",
    fullscreenTitle: "Entrar em Tela Cheia",
    gamingModeTitle: "Modo de Jogo",
    trackpadModeTitle: "Modo Trackpad",
    buttons: {
        videoStreamEnableTitle: "Ativar Stream de Vídeo",
        videoStreamDisableTitle: "Desativar Stream de Vídeo",
        audioStreamEnableTitle: "Ativar Stream de Áudio",
        audioStreamDisableTitle: "Desativar Stream de Áudio",
        microphoneEnableTitle: "Ativar Microfone",
        microphoneDisableTitle: "Desativar Microfone",
        gamepadEnableTitle: "Ativar Entrada de Gamepad",
        gamepadDisableTitle: "Desativar Entrada de Gamepad",
        virtualKeyboardButtonTitle: "Exibir Teclado",
        h264FullColorEnableTitle: "Ativar H.264 Cor Completa",
        h264FullColorDisableTitle: "Desativar H.264 Cor Completa",
        h264StreamingModeDisableTitle: "Desativar Turbo",
        h264StreamingModeEnableTitle: "Ativar Turbo",
        useCpuEnableTitle: "Ativar Codificação Forçada por CPU (Substitui nvenc/vaapi)",
        useCpuDisableTitle: "Desativar Codificação Forçada por CPU (Substitui nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Ativar Melhoria de Estáticos (Limpa porções estáticas da tela)",
        usePaintOverQualityDisableTitle: "Desativar Melhoria de Estáticos (Limpa porções estáticas da tela)",
        binaryClipboardEnableTitle: "Ativar Área de Transferência de Imagens",
        binaryClipboardDisableTitle: "Desativar Área de Transferência de Imagens",
    },
    sections: {
        video: {
            title: "Configurações de Vídeo",
            encoderLabel: "Codificador:",
            framerateLabel: "Quadros por segundo ({framerate} FPS):",
            bitrateLabel: "Bitrate de Vídeo ({bitrate} Mbps):",
            bufferLabelImmediate: "Tamanho do Buffer de Vídeo (0 (Imediato)):",
            bufferLabelFrames: "Tamanho do Buffer de Vídeo ({videoBufferSize} quadros):",
            crfLabel: "CRF de Vídeo ({crf}):",
            fullColorLabel: "Cor Completa 4:4:4",
            streamingModeDetails: "O modo Turbo desativa toda a lógica VNC e codifica todos os quadros como um codificador de vídeo tradicional.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "Codificação por CPU",
            jpegQualityLabel: "Qualidade Base: {jpegQuality}",
            paintOverJpegQualityLabel: "Qualidade de Sobreposição: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF de Melhoria de Estáticos ({crf}):",
            usePaintOverQualityLabel: "Usar Melhoria de Estáticos",
        },
        audio: {
            title: "Configurações de Áudio",
            bitrateLabel: "Bitrate de Áudio ({bitrate} kbps):",
            inputLabel: "Entrada (Microfone):",
            outputLabel: "Saída (Alto-falante):",
            outputNotSupported: "A seleção de dispositivo de saída não é suportada por este navegador.",
            deviceErrorDefault: "Erro ao listar dispositivos de áudio: {errorName}",
            deviceErrorPermission: "Permissão negada. Permita o acesso ao microfone nas configurações do navegador para selecionar dispositivos.",
            deviceErrorNotFound: "Nenhum dispositivo de áudio encontrado.",
            defaultInputLabelFallback: "Dispositivo de Entrada {index}",
            defaultOutputLabelFallback: "Dispositivo de Saída {index}",
        },
        screen: {
            title: "Configurações de Tela",
            presetLabel: "Predefinição:",
            resolutionPresetSelect: "-- Selecionar Predefinição --",
            widthLabel: "Largura:",
            heightLabel: "Altura:",
            widthPlaceholder: "ex: 1920",
            heightPlaceholder: "ex: 1080",
            setManualButton: "Definir Resolução Manual",
            resetButton: "Redefinir para Janela",
            scaleLocallyLabel: "Escalar Localmente:",
            scaleLocallyOn: "LIGADO",
            scaleLocallyOff: "DESLIGADO",
            scaleLocallyTitleEnable: "Ativar Escala Local (Manter Proporção)",
            scaleLocallyTitleDisable: "Desativar Escala Local (Usar Resolução Exata)",
            uiScalingLabel: "Escala da Interface:",
            hidpiLabel: "HiDPI (Pixel Perfeito)",
            hidpiEnableTitle: "Ativar HiDPI (Pixel Perfeito)",
            hidpiDisableTitle: "Desativar HiDPI (Usar dimensionamento CSS)",
            antiAliasingLabel: "Anti-aliasing",
            antiAliasingEnableTitle: "Ativar anti-aliasing (suavizar ao escalar)",
            antiAliasingDisableTitle: "Desativar anti-aliasing (forçar pixelização)",
            useNativeCursorStylesLabel: "Usar cursores CSS",
            useNativeCursorStylesEnableTitle: "Usar renderização de cursor CSS (Substituir cursores do sistema)",
            useNativeCursorStylesDisableTitle: "Usar renderização de cursor em canvas (Pintar no canvas)",
            addScreenTitle: "Adicionar uma segunda tela",
            addScreenButton: "Adicionar Tela +",
        },
        stats: {
            title: "Estatísticas",
            cpuLabel: "CPU",
            gpuLabel: "Uso de GPU",
            sysMemLabel: "Mem Sistema",
            gpuMemLabel: "Mem GPU",
            fpsLabel: "FPS",
            audioLabel: "Áudio",
            tooltipCpu: "Uso de CPU: {value}%",
            tooltipGpu: "Uso de GPU: {value}%",
            tooltipSysMem: "Memória do Sistema: {used} / {total}",
            tooltipGpuMem: "Memória da GPU: {used} / {total}",
            tooltipFps: "FPS do Cliente: {value}",
            tooltipAudio: "Buffers de Áudio: {value}",
            tooltipMemoryNA: "N/D",
            bandwidthLabel: "Largura de Banda",
            tooltipBandwidth: "Largura de Banda: {value}mbps",
            latencyLabel: "Latência",
            tooltipLatency: "Latência de Ida e Volta: {value}ms",
        },
        clipboard: {
            title: "Área de Transferência",
            label: "Área de Transferência do Servidor:",
            placeholder: "Conteúdo da área de transferência do servidor...",
            binaryModeLabel: "Suporte a Imagens",
            binaryModeDetails: "Permite copiar e colar imagens de e para a sessão remota.",
        },
        files: {
            title: "Arquivos",
            uploadButton: "Carregar Arquivos",
            uploadButtonTitle: "Carregar arquivos para a sessão remota",
            downloadButtonTitle: "Baixar Arquivos",
        },
        gamepads: {
            title: "Gamepads",
            noActivity: "Nenhuma atividade de gamepad detectada ainda...",
            touchEnableTitle: "Ativar Gamepad Tátil",
            touchDisableTitle: "Desativar Gamepad Tátil",
            touchActiveLabel: "Gamepad Tátil: LIGADO",
            touchInactiveLabel: "Gamepad Tátil: DESLIGADO",
            physicalHiddenForTouch: "A exibição de gamepads físicos fica oculta enquanto o gamepad tátil está ativo.",
            noActivityMobileOrEnableTouch: "Sem gamepads físicos. Ative o gamepad tátil ou conecte um controle."
        },
        apps: {
          title: "Aplicativos",
          openButtonTitle: "Gerenciar Aplicativos",
          openButton: "Gerenciar Aplicativos"
        },
        sharing: {
            title: "Compartilhamento"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Fechar modal de aplicativos",
        loading: "Carregando aplicativos...",
        errorLoading: "Falha ao carregar dados dos aplicativos. Por favor, tente novamente.",
        searchPlaceholder: "Buscar aplicativos...",
        noAppsFound: "Nenhum aplicativo encontrado correspondente à sua busca.",
        backButton: "Voltar para a lista",
        installButton: "Instalar",
        updateButton: "Atualizar",
        removeButton: "Remover",
        installingMessage: "Simulando instalação para: {{appName}}",
        removingMessage: "Simulando remoção para: {{appName}}",
        updatingMessage: "Simulando atualização para: {{appName}}",
        installedBadge: "Instalado"
    },
    notifications: {
        closeButtonAlt: "Fechar notificação para {fileName}",
        uploading: "Carregando... {progress}%",
        uploadComplete: "Carregamento Completo",
        uploadFailed: "Falha no Carregamento",
        errorPrefix: "Erro:",
        unknownError: "Ocorreu um erro desconhecido.",
        copiedTitle: "Copiado: {label}",
        copiedMessage: "Link copiado para a área de transferência: {textToCopy}",
        copyFailedTitle: "Falha ao Copiar: {label}",
        copyFailedError: "Não foi possível copiar o link para a área de transferência.",
        scalingTitle: "Escala Atualizada: Ação Necessária",
        scalingMessage: "Nova escala aplicada. Algumas aplicações ou ambientes de trabalho podem exigir um reinício.",
    },
    alerts: {
        invalidResolution: "Por favor, insira inteiros positivos válidos para Largura e Altura.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Fechar modal de arquivos",
        iframeTitle: "Arquivos para Download"
    }
};

// --- French Translations ---
const fr = {
    selkiesLogoAlt: "Logo Selkies",
    toggleThemeTitle: "Changer de thème",
    fullscreenTitle: "Passer en plein écran",
    gamingModeTitle: "Mode Jeu",
    trackpadModeTitle: "Mode Trackpad",
    buttons: {
        videoStreamEnableTitle: "Activer le flux vidéo",
        videoStreamDisableTitle: "Désactiver le flux vidéo",
        audioStreamEnableTitle: "Activer le flux audio",
        audioStreamDisableTitle: "Désactiver le flux audio",
        microphoneEnableTitle: "Activer le microphone",
        microphoneDisableTitle: "Désactiver le microphone",
        gamepadEnableTitle: "Activer l'entrée manette",
        gamepadDisableTitle: "Désactiver l'entrée manette",
        virtualKeyboardButtonTitle: "Afficher le Clavier",
        h264FullColorEnableTitle: "Activer H.264 Couleur Complète",
        h264FullColorDisableTitle: "Désactiver H.264 Couleur Complète",
        h264StreamingModeDisableTitle: "Désactiver le mode Turbo",
        h264StreamingModeEnableTitle: "Activer le mode Turbo",
        useCpuEnableTitle: "Activer l'encodage forcé par CPU (Remplace nvenc/vaapi)",
        useCpuDisableTitle: "Désactiver l'encodage forcé par CPU (Remplace nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Activer le raffinage statique (Nettoie les parties statiques de l'écran)",
        usePaintOverQualityDisableTitle: "Désactiver le raffinage statique (Nettoie les parties statiques de l'écran)",
        binaryClipboardEnableTitle: "Activer le presse-papiers d'images",
        binaryClipboardDisableTitle: "Désactiver le presse-papiers d'images",
    },
    sections: {
        video: {
            title: "Paramètres vidéo",
            encoderLabel: "Encodeur :",
            framerateLabel: "Images par seconde ({framerate} FPS) :",
            bitrateLabel: "Débit vidéo ({bitrate} Mbps) :",
            bufferLabelImmediate: "Taille du tampon vidéo (0 (Immédiat)) :",
            bufferLabelFrames: "Taille du tampon vidéo ({videoBufferSize} images) :",
            crfLabel: "CRF Vidéo ({crf}) :",
            fullColorLabel: "Couleur Complète 4:4:4",
            streamingModeDetails: "Le mode Turbo désactive toute la logique VNC et encode toutes les trames comme un encodeur vidéo traditionnel.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "Encodage CPU",
            jpegQualityLabel: "Qualité de base : {jpegQuality}",
            paintOverJpegQualityLabel: "Qualité de la surimpression : {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF du raffinage statique ({crf}):",
            usePaintOverQualityLabel: "Utiliser le raffinage statique",
        },
        audio: {
            title: "Paramètres audio",
            bitrateLabel: "Débit audio ({bitrate} kbps) :",
            inputLabel: "Entrée (Microphone) :",
            outputLabel: "Sortie (Haut-parleur) :",
            outputNotSupported: "La sélection du périphérique de sortie n'est pas prise en charge par ce navigateur.",
            deviceErrorDefault: "Erreur lors de l'énumération des périphériques audio : {errorName}",
            deviceErrorPermission: "Autorisation refusée. Veuillez autoriser l'accès au microphone dans les paramètres du navigateur pour sélectionner des périphériques.",
            deviceErrorNotFound: "Aucun périphérique audio trouvé.",
            defaultInputLabelFallback: "Périphérique d'entrée {index}",
            defaultOutputLabelFallback: "Périphérique de sortie {index}",
        },
        screen: {
            title: "Paramètres d'écran",
            presetLabel: "Préréglage :",
            resolutionPresetSelect: "-- Sélectionner un préréglage --",
            widthLabel: "Largeur :",
            heightLabel: "Hauteur :",
            widthPlaceholder: "ex: 1920",
            heightPlaceholder: "ex: 1080",
            setManualButton: "Définir la résolution manuelle",
            resetButton: "Réinitialiser à la fenêtre",
            scaleLocallyLabel: "Mise à l'échelle locale :",
            scaleLocallyOn: "OUI",
            scaleLocallyOff: "NON",
            scaleLocallyTitleEnable: "Activer la mise à l'échelle locale (Conserver les proportions)",
            scaleLocallyTitleDisable: "Désactiver la mise à l'échelle locale (Utiliser la résolution exacte)",
            uiScalingLabel: "Mise à l'échelle de l'interface :",
            hidpiLabel: "HiDPI (Pixel Perfect)",
            hidpiEnableTitle: "Activer HiDPI (Pixel Perfect)",
            hidpiDisableTitle: "Désactiver HiDPI (Utiliser la mise à l'échelle CSS)",
            antiAliasingLabel: "Anticrénelage",
            antiAliasingEnableTitle: "Activer l'anticrénelage (lisser à la mise à l'échelle)",
            antiAliasingDisableTitle: "Désactiver l'anticrénelage (forcer la pixellisation)",
            useNativeCursorStylesLabel: "Utiliser les curseurs CSS",
            useNativeCursorStylesEnableTitle: "Utiliser le rendu des curseurs CSS (Remplacer les curseurs système)",
            useNativeCursorStylesDisableTitle: "Utiliser le rendu des curseurs sur canevas (Dessiner sur le canevas)",
            addScreenTitle: "Ajouter un deuxième écran",
            addScreenButton: "Ajouter un écran +",
        },
        stats: {
            title: "Statistiques",
            cpuLabel: "CPU",
            gpuLabel: "Utilisation GPU",
            sysMemLabel: "Mém. Système",
            gpuMemLabel: "Mém. GPU",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "Utilisation CPU : {value}%",
            tooltipGpu: "Utilisation GPU : {value}%",
            tooltipSysMem: "Mémoire système : {used} / {total}",
            tooltipGpuMem: "Mémoire GPU : {used} / {total}",
            tooltipFps: "FPS Client : {value}",
            tooltipAudio: "Tampons audio : {value}",
            tooltipMemoryNA: "N/D",
            bandwidthLabel: "Bande Passante",
            tooltipBandwidth: "Bande Passante : {value}mbps",
            latencyLabel: "Latence",
            tooltipLatency: "Latence Aller-Retour : {value}ms",
        },
        clipboard: {
            title: "Presse-papiers",
            label: "Presse-papiers du serveur :",
            placeholder: "Contenu du presse-papiers depuis le serveur...",
            binaryModeLabel: "Support d'images",
            binaryModeDetails: "Permet de copier et coller des images depuis et vers la session distante.",
        },
        files: {
            title: "Fichiers",
            uploadButton: "Téléverser des fichiers",
            uploadButtonTitle: "Téléverser des fichiers vers la session distante",
            downloadButtonTitle: "Télécharger les Fichiers",
        },
        gamepads: {
            title: "Manettes",
            noActivity: "Aucune activité de manette détectée pour le moment...",
            touchEnableTitle: "Activer la manette tactile",
            touchDisableTitle: "Désactiver la manette tactile",
            touchActiveLabel: "Manette tactile : ACTIVÉE",
            touchInactiveLabel: "Manette tactile : DÉSACTIVÉE",
            physicalHiddenForTouch: "L'affichage des manettes physiques est masqué lorsque la manette tactile est active.",
            noActivityMobileOrEnableTouch: "Aucune manette physique. Activez la manette tactile ou connectez un contrôleur."
        },
        apps: {
          title: "Applications",
          openButtonTitle: "Gérer les applications",
          openButton: "Gérer les applications"
        },
        sharing: {
            title: "Partage"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Portable)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Fermer la modale des applications",
        loading: "Chargement des applications...",
        errorLoading: "Échec du chargement des données des applications. Veuillez réessayer.",
        searchPlaceholder: "Rechercher des applications...",
        noAppsFound: "Aucune application trouvée correspondant à votre recherche.",
        backButton: "Retour à la liste",
        installButton: "Installer",
        updateButton: "Mettre à jour",
        removeButton: "Supprimer",
        installingMessage: "Simulation de l'installation pour : {{appName}}",
        removingMessage: "Simulation de la suppression pour : {{appName}}",
        updatingMessage: "Simulation de la mise à jour pour : {{appName}}",
        installedBadge: "Installé"
    },
    notifications: {
        closeButtonAlt: "Fermer la notification pour {fileName}",
        uploading: "Téléversement... {progress}%",
        uploadComplete: "Téléversement terminé",
        uploadFailed: "Échec du téléversement",
        errorPrefix: "Erreur :",
        unknownError: "Une erreur inconnue s'est produite.",
        copiedTitle: "Copié : {label}",
        copiedMessage: "Lien copié dans le presse-papiers : {textToCopy}",
        copyFailedTitle: "Échec de la copie : {label}",
        copyFailedError: "Impossible de copier le lien dans le presse-papiers.",
        scalingTitle: "Mise à l'échelle mise à jour : Action requise",
        scalingMessage: "Nouvelle mise à l'échelle appliquée. Certaines applications ou certains environnements de bureau могут nécessiter un redémarrage.",
    },
    alerts: {
        invalidResolution: "Veuillez entrer des entiers positifs valides pour la Largeur et la Hauteur.",
    },
    byteUnits: ['Octets', 'Ko', 'Mo', 'Go', 'To', 'Po', 'Eo', 'Zo', 'Yo'], // French often uses 'o' for octet
    zeroBytes: "0 Octets",
    filesModal: {
        closeAlt: "Fermer la modale des fichiers",
        iframeTitle: "Fichiers téléchargeables"
    }
};

// --- Russian Translations ---
const ru = {
    selkiesLogoAlt: "Логотип Selkies",
    toggleThemeTitle: "Переключить тему",
    fullscreenTitle: "Войти в полноэкранный режим",
    gamingModeTitle: "Игровой режим",
    trackpadModeTitle: "Режим трекпада",
    buttons: {
        videoStreamEnableTitle: "Включить видеопоток",
        videoStreamDisableTitle: "Отключить видеопоток",
        audioStreamEnableTitle: "Включить аудиопоток",
        audioStreamDisableTitle: "Отключить аудиопоток",
        microphoneEnableTitle: "Включить микрофон",
        microphoneDisableTitle: "Отключить микрофон",
        gamepadEnableTitle: "Включить ввод с геймпада",
        gamepadDisableTitle: "Отключить ввод с геймпада",
        virtualKeyboardButtonTitle: "Показать Клавиатуру",
        h264FullColorEnableTitle: "Включить H.264 Полный цвет",
        h264FullColorDisableTitle: "Отключить H.264 Полный цвет",
        h264StreamingModeDisableTitle: "Отключить Турбо",
        h264StreamingModeEnableTitle: "Включить Турбо",
        useCpuEnableTitle: "Включить принудительное кодирование ЦП (Переопределяет nvenc/vaapi)",
        useCpuDisableTitle: "Отключить принудительное кодирование ЦП (Переопределяет nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Включить улучшение статики (Очищает статичные части экрана)",
        usePaintOverQualityDisableTitle: "Отключить улучшение статики (Очищает статичные части экрана)",
        binaryClipboardEnableTitle: "Включить буфер обмена изображений",
        binaryClipboardDisableTitle: "Отключить буфер обмена изображений",
    },
    sections: {
        video: {
            title: "Настройки видео",
            encoderLabel: "Кодировщик:",
            framerateLabel: "Кадров в секунду ({framerate} FPS):",
            bitrateLabel: "Битрейт видео ({bitrate} Мбит/с):",
            bufferLabelImmediate: "Размер буфера видео (0 (Немедленно)):",
            bufferLabelFrames: "Размер буфера видео ({videoBufferSize} кадров):",
            crfLabel: "CRF видео ({crf}):",
            fullColorLabel: "Полный цвет 4:4:4",
            streamingModeDetails: "Режим Турбо отключает всю логику VNC и кодирует все кадры как традиционный видеокодер.",
            streamingModeLabel: "Турбо",
            useCpuLabel: "Кодирование ЦП",
            jpegQualityLabel: "Базовое качество: {jpegQuality}",
            paintOverJpegQualityLabel: "Качество дорисовки: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF улучшения статики ({crf}):",
            usePaintOverQualityLabel: "Использовать улучшение статики",
        },
        audio: {
            title: "Настройки аудио",
            bitrateLabel: "Битрейт аудио ({bitrate} кбит/с):",
            inputLabel: "Вход (Микрофон):",
            outputLabel: "Выход (Динамик):",
            outputNotSupported: "Выбор устройства вывода не поддерживается этим браузером.",
            deviceErrorDefault: "Ошибка при перечислении аудиоустройств: {errorName}",
            deviceErrorPermission: "Доступ запрещен. Пожалуйста, разрешите доступ к микрофону в настройках браузера для выбора устройств.",
            deviceErrorNotFound: "Аудиоустройства не найдены.",
            defaultInputLabelFallback: "Устройство ввода {index}",
            defaultOutputLabelFallback: "Устройство вывода {index}",
        },
        screen: {
            title: "Настройки экрана",
            presetLabel: "Предустановка:",
            resolutionPresetSelect: "-- Выбрать предустановку --",
            widthLabel: "Ширина:",
            heightLabel: "Высота:",
            widthPlaceholder: "напр., 1920",
            heightPlaceholder: "напр., 1080",
            setManualButton: "Установить ручное разрешение",
            resetButton: "Сбросить до окна",
            scaleLocallyLabel: "Масштабировать локально:",
            scaleLocallyOn: "ВКЛ",
            scaleLocallyOff: "ВЫКЛ",
            scaleLocallyTitleEnable: "Включить локальное масштабирование (Сохранять пропорции)",
            scaleLocallyTitleDisable: "Отключить локальное масштабирование (Использовать точное разрешение)",
            uiScalingLabel: "Масштаб интерфейса:",
            hidpiLabel: "HiDPI (Пиксельная точность)",
            hidpiEnableTitle: "Включить HiDPI (Пиксельная точность)",
            hidpiDisableTitle: "Отключить HiDPI (Использовать масштабирование CSS)",
            antiAliasingLabel: "Сглаживание",
            antiAliasingEnableTitle: "Включить сглаживание (плавно при масштабировании)",
            antiAliasingDisableTitle: "Отключить сглаживание (принудительно пикселизировать)",
            useNativeCursorStylesLabel: "Использовать курсоры CSS",
            useNativeCursorStylesEnableTitle: "Использовать рендеринг курсора CSS (Заменяет системные курсоры)",
            useNativeCursorStylesDisableTitle: "Использовать отрисовку курсора на холсте (Рисовать на холсте)",
            addScreenTitle: "Добавить второй экран",
            addScreenButton: "Добавить экран +",
        },
        stats: {
            title: "Статистика",
            cpuLabel: "ЦП",
            gpuLabel: "Загрузка ГП",
            sysMemLabel: "Память сист.",
            gpuMemLabel: "Память ГП",
            fpsLabel: "FPS",
            audioLabel: "Аудио",
            tooltipCpu: "Загрузка ЦП: {value}%",
            tooltipGpu: "Загрузка ГП: {value}%",
            tooltipSysMem: "Системная память: {used} / {total}",
            tooltipGpuMem: "Память ГП: {used} / {total}",
            tooltipFps: "FPS клиента: {value}",
            tooltipAudio: "Аудиобуферы: {value}",
            tooltipMemoryNA: "Н/Д",
            bandwidthLabel: "Пропускная способность",
            tooltipBandwidth: "Пропускная способность: {value}mbps",
            latencyLabel: "Задержка",
            tooltipLatency: "Задержка приема-передачи: {value}ms",
        },
        clipboard: {
            title: "Буфер обмена",
            label: "Буфер обмена сервера:",
            placeholder: "Содержимое буфера обмена с сервера...",
            binaryModeLabel: "Поддержка изображений",
            binaryModeDetails: "Позволяет копировать и вставлять изображения в удаленную сессию и из нее.",
        },
        files: {
            title: "Файлы",
            uploadButton: "Загрузить файлы",
            uploadButtonTitle: "Загрузить файлы в удаленную сессию",
            downloadButtonTitle: "Скачать Файлы",
        },
        gamepads: {
            title: "Геймпады",
            noActivity: "Активность геймпада пока не обнаружена...",
            touchEnableTitle: "Включить сенсорный геймпад",
            touchDisableTitle: "Отключить сенсорный геймпад",
            touchActiveLabel: "Сенсорный геймпад: ВКЛ",
            touchInactiveLabel: "Сенсорный геймпад: ВЫКЛ",
            physicalHiddenForTouch: "Отображение физических геймпадов скрыто, пока активен сенсорный геймпад.",
            noActivityMobileOrEnableTouch: "Физические геймпады отсутствуют. Включите сенсорный геймпад или подключите контроллер."
        },
        apps: {
          title: "Приложения",
          openButtonTitle: "Управление приложениями",
          openButton: "Управление приложениями"
        },
        sharing: {
            title: "Общий доступ"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Ноутбук)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Закрыть модальное окно приложений",
        loading: "Загрузка приложений...",
        errorLoading: "Не удалось загрузить данные приложений. Пожалуйста, попробуйте еще раз.",
        searchPlaceholder: "Поиск приложений...",
        noAppsFound: "Приложения, соответствующие вашему поиску, не найдены.",
        backButton: "Назад к списку",
        installButton: "Установить",
        updateButton: "Обновить",
        removeButton: "Удалить",
        installingMessage: "Симуляция установки для: {{appName}}",
        removingMessage: "Симуляция удаления для: {{appName}}",
        updatingMessage: "Симуляция обновления для: {{appName}}",
        installedBadge: "Установлено"
    },
    notifications: {
        closeButtonAlt: "Закрыть уведомление для {fileName}",
        uploading: "Загрузка... {progress}%",
        uploadComplete: "Загрузка завершена",
        uploadFailed: "Ошибка загрузки",
        errorPrefix: "Ошибка:",
        unknownError: "Произошла неизвестная ошибка.",
        copiedTitle: "Скопировано: {label}",
        copiedMessage: "Ссылка скопирована в буфер обмена: {textToCopy}",
        copyFailedTitle: "Ошибка копирования: {label}",
        copyFailedError: "Не удалось скопировать ссылку в буфер обмена.",
        scalingTitle: "Масштабирование обновлено: Требуется действие",
        scalingMessage: "Новое масштабирование применено. Некоторые приложения или среды рабочего стола могут потребовать перезапуска.",
    },
    alerts: {
        invalidResolution: "Пожалуйста, введите действительные положительные целые числа для Ширины и Высоты.",
    },
    byteUnits: ['Байты', 'КБ', 'МБ', 'ГБ', 'ТБ', 'ПБ', 'ЭБ', 'ЗБ', 'ЙБ'], // Russian uses Cyrillic abbreviations
    zeroBytes: "0 Байт",
    filesModal: {
        closeAlt: "Закрыть модальное окно файлов",
        iframeTitle: "Файлы для скачивания"
    }
};

// --- German Translations ---
const de = {
    selkiesLogoAlt: "Selkies Logo",
    toggleThemeTitle: "Theme wechseln",
    fullscreenTitle: "Vollbildmodus aktivieren",
    gamingModeTitle: "Gaming-Modus",
    trackpadModeTitle: "Trackpad-Modus",
    buttons: {
        videoStreamEnableTitle: "Videostream aktivieren",
        videoStreamDisableTitle: "Videostream deaktivieren",
        audioStreamEnableTitle: "Audiostream aktivieren",
        audioStreamDisableTitle: "Audiostream deaktivieren",
        microphoneEnableTitle: "Mikrofon aktivieren",
        microphoneDisableTitle: "Mikrofon deaktivieren",
        gamepadEnableTitle: "Gamepad-Eingabe aktivieren",
        gamepadDisableTitle: "Gamepad-Eingabe deaktivieren",
        virtualKeyboardButtonTitle: "Tastatur einblenden",
        h264FullColorEnableTitle: "H.264 Vollfarbe aktivieren",
        h264FullColorDisableTitle: "H.264 Vollfarbe deaktivieren",
        h264StreamingModeDisableTitle: "Turbo deaktivieren",
        h264StreamingModeEnableTitle: "Turbo aktivieren",
        useCpuEnableTitle: "Erzwungene CPU-Kodierung aktivieren (Überschreibt nvenc/vaapi)",
        useCpuDisableTitle: "Erzwungene CPU-Kodierung deaktivieren (Überschreibt nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Statische Bildverbesserung aktivieren (Bereinigt statische Bereiche des Bildschirms)",
        usePaintOverQualityDisableTitle: "Statische Bildverbesserung deaktivieren (Bereinigt statische Bereiche des Bildschirms)",
        binaryClipboardEnableTitle: "Bild-Zwischenablage aktivieren",
        binaryClipboardDisableTitle: "Bild-Zwischenablage deaktivieren",
    },
    sections: {
        video: {
            title: "Videoeinstellungen",
            encoderLabel: "Encoder:",
            framerateLabel: "Bilder pro Sekunde ({framerate} FPS):",
            bitrateLabel: "Video-Bitrate ({bitrate} Mbps):",
            bufferLabelImmediate: "Video-Puffergröße (0 (Sofort)):",
            bufferLabelFrames: "Video-Puffergröße ({videoBufferSize} Frames):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "Vollfarbe 4:4:4",
            streamingModeDetails: "Der Turbo-Modus deaktiviert die gesamte VNC-Logik und kodiert alle Frames wie ein herkömmlicher Video-Encoder.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU-Kodierung",
            jpegQualityLabel: "Basisqualität: {jpegQuality}",
            paintOverJpegQualityLabel: "Übermalungsqualität: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF für Bildverbesserung ({crf}):",
            usePaintOverQualityLabel: "Statische Bildverbesserung nutzen",
        },
        audio: {
            title: "Audioeinstellungen",
            bitrateLabel: "Audio-Bitrate ({bitrate} kbps):",
            inputLabel: "Eingang (Mikrofon):",
            outputLabel: "Ausgang (Lautsprecher):",
            outputNotSupported: "Die Auswahl des Ausgabegeräts wird von diesem Browser nicht unterstützt.",
            deviceErrorDefault: "Fehler beim Auflisten der Audiogeräte: {errorName}",
            deviceErrorPermission: "Berechtigung verweigert. Bitte erlauben Sie den Mikrofonzugriff in den Browsereinstellungen, um Geräte auszuwählen.",
            deviceErrorNotFound: "Keine Audiogeräte gefunden.",
            defaultInputLabelFallback: "Eingabegerät {index}",
            defaultOutputLabelFallback: "Ausgabegerät {index}",
        },
        screen: {
            title: "Bildschirmeinstellungen",
            presetLabel: "Voreinstellung:",
            resolutionPresetSelect: "-- Voreinstellung wählen --",
            widthLabel: "Breite:",
            heightLabel: "Höhe:",
            widthPlaceholder: "z.B. 1920",
            heightPlaceholder: "z.B. 1080",
            setManualButton: "Manuelle Auflösung festlegen",
            resetButton: "Auf Fenster zurücksetzen",
            scaleLocallyLabel: "Lokal skalieren:",
            scaleLocallyOn: "AN",
            scaleLocallyOff: "AUS",
            scaleLocallyTitleEnable: "Lokale Skalierung aktivieren (Seitenverhältnis beibehalten)",
            scaleLocallyTitleDisable: "Lokale Skalierung deaktivieren (Genaue Auflösung verwenden)",
            uiScalingLabel: "UI-Skalierung:",
            hidpiLabel: "HiDPI (Pixelgenau)",
            hidpiEnableTitle: "HiDPI aktivieren (Pixelgenau)",
            hidpiDisableTitle: "HiDPI deaktivieren (CSS-Skalierung verwenden)",
            antiAliasingLabel: "Kantenglättung",
            antiAliasingEnableTitle: "Kantenglättung aktivieren (Glättung bei Skalierung)",
            antiAliasingDisableTitle: "Kantenglättung deaktivieren (Verpixelung erzwingen)",
            useNativeCursorStylesLabel: "CSS-Cursor verwenden",
            useNativeCursorStylesEnableTitle: "CSS-Cursor-Rendering verwenden (Systemcursor ersetzen)",
            useNativeCursorStylesDisableTitle: "Canvas-Cursor-Rendering verwenden (Auf Canvas zeichnen)",
            addScreenTitle: "Einen zweiten Bildschirm hinzufügen",
            addScreenButton: "Bildschirm hinzufügen +",
        },
        stats: {
            title: "Statistiken",
            cpuLabel: "CPU",
            gpuLabel: "GPU-Auslastung",
            sysMemLabel: "Sys-Speicher",
            gpuMemLabel: "GPU-Speicher",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "CPU-Auslastung: {value}%",
            tooltipGpu: "GPU-Auslastung: {value}%",
            tooltipSysMem: "Systemspeicher: {used} / {total}",
            tooltipGpuMem: "GPU-Speicher: {used} / {total}",
            tooltipFps: "Client FPS: {value}",
            tooltipAudio: "Audio-Puffer: {value}",
            tooltipMemoryNA: "N/V",
            bandwidthLabel: "Bandbreite",
            tooltipBandwidth: "Bandbreite: {value}mbps",
            latencyLabel: "Latenz",
            tooltipLatency: "Round-Trip-Latenz: {value}ms",
        },
        clipboard: {
            title: "Zwischenablage",
            label: "Server-Zwischenablage:",
            placeholder: "Inhalt der Zwischenablage vom Server...",
            binaryModeLabel: "Bildunterstützung",
            binaryModeDetails: "Ermöglicht das Kopieren und Einfügen von Bildern in die und aus der Remote-Sitzung.",
        },
        files: {
            title: "Dateien",
            uploadButton: "Dateien hochladen",
            uploadButtonTitle: "Dateien zur Remote-Sitzung hochladen",
            downloadButtonTitle: "Dateien herunterladen",
        },
        gamepads: {
            title: "Gamepads",
            noActivity: "Bisher keine Gamepad-Aktivität erkannt...",
            touchEnableTitle: "Touch-Gamepad aktivieren",
            touchDisableTitle: "Touch-Gamepad deaktivieren",
            touchActiveLabel: "Touch-Gamepad: AN",
            touchInactiveLabel: "Touch-Gamepad: AUS",
            physicalHiddenForTouch: "Die Anzeige physischer Gamepads ist ausgeblendet, während das Touch-Gamepad aktiv ist.",
            noActivityMobileOrEnableTouch: "Keine physischen Gamepads. Aktivieren Sie das Touch-Gamepad oder schließen Sie einen Controller an."
        },
        apps: {
          title: "Anwendungen",
          openButtonTitle: "Anwendungen verwalten",
          openButton: "Anwendungen verwalten"
        },
        sharing: {
            title: "Teilen"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Anwendungsmodal schließen",
        loading: "Anwendungen werden geladen...",
        errorLoading: "Fehler beim Laden der Anwendungsdaten. Bitte versuchen Sie es erneut.",
        searchPlaceholder: "Anwendungen suchen...",
        noAppsFound: "Keine Anwendungen gefunden, die Ihrer Suche entsprechen.",
        backButton: "Zurück zur Liste",
        installButton: "Installieren",
        updateButton: "Aktualisieren",
        removeButton: "Entfernen",
        installingMessage: "Simulation der Installation für: {{appName}}",
        removingMessage: "Simulation der Entfernung für: {{appName}}",
        updatingMessage: "Simulation der Aktualisierung für: {{appName}}",
        installedBadge: "Installiert"
    },
    notifications: {
        closeButtonAlt: "Benachrichtigung für {fileName} schließen",
        uploading: "Hochladen... {progress}%",
        uploadComplete: "Hochladen abgeschlossen",
        uploadFailed: "Hochladen fehlgeschlagen",
        errorPrefix: "Fehler:",
        unknownError: "Ein unbekannter Fehler ist aufgetreten.",
        copiedTitle: "Kopiert: {label}",
        copiedMessage: "Link in die Zwischenablage kopiert: {textToCopy}",
        copyFailedTitle: "Kopieren fehlgeschlagen: {label}",
        copyFailedError: "Link konnte nicht in die Zwischenablage kopiert werden.",
        scalingTitle: "Skalierung aktualisiert: Aktion erforderlich",
        scalingMessage: "Neue Skalierung angewendet. Einige Anwendungen oder Desktop-Umgebungen erfordern möglicherweise einen Neustart.",
    },
    alerts: {
        invalidResolution: "Bitte geben Sie gültige positive ganze Zahlen für Breite und Höhe ein.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Dateimodal schließen",
        iframeTitle: "Herunterladbare Dateien"
    }
};

// --- Turkish Translations ---
const tr = {
    selkiesLogoAlt: "Selkies Logosu",
    toggleThemeTitle: "Temayı Değiştir",
    fullscreenTitle: "Tam Ekrana Gir",
    gamingModeTitle: "Oyun Modu",
    trackpadModeTitle: "Dokunmatik Yüzey Modu",
    buttons: {
        videoStreamEnableTitle: "Video Akışını Etkinleştir",
        videoStreamDisableTitle: "Video Akışını Devre Dışı Bırak",
        audioStreamEnableTitle: "Ses Akışını Etkinleştir",
        audioStreamDisableTitle: "Ses Akışını Devre Dışı Bırak",
        microphoneEnableTitle: "Mikrofonu Etkinleştir",
        microphoneDisableTitle: "Mikrofonu Devre Dışı Bırak",
        gamepadEnableTitle: "Oyun Kumandası Girişini Etkinleştir",
        gamepadDisableTitle: "Oyun Kumandası Girişini Devre Dışı Bırak",
        virtualKeyboardButtonTitle: "Klavyeyi Göster",
        h264FullColorEnableTitle: "H.264 Tam Renk Etkinleştir",
        h264FullColorDisableTitle: "H.264 Tam Renk Devre Dışı Bırak",
        h264StreamingModeDisableTitle: "Turbo'yu Devre Dışı Bırak",
        h264StreamingModeEnableTitle: "Turbo'yu Etkinleştir",
        useCpuEnableTitle: "CPU Kodlamasını Zorla Etkinleştir (nvenc/vaapi'yi geçersiz kılar)",
        useCpuDisableTitle: "CPU Kodlamasını Zorla Devre Dışı Bırak (nvenc/vaapi'yi geçersiz kılar)",
        usePaintOverQualityEnableTitle: "Statik İyileştirmeyi Etkinleştir (Ekranın statik kısımlarını temizler)",
        usePaintOverQualityDisableTitle: "Statik İyileştirmeyi Devre Dışı Bırak (Ekranın statik kısımlarını temizler)",
        binaryClipboardEnableTitle: "Resim Panosunu Etkinleştir",
        binaryClipboardDisableTitle: "Resim Panosunu Devre Dışı Bırak",
    },
    sections: {
        video: {
            title: "Video Ayarları",
            encoderLabel: "Kodlayıcı:",
            framerateLabel: "Saniyedeki Kare Sayısı ({framerate} FPS):",
            bitrateLabel: "Video Bit Hızı ({bitrate} Mbps):",
            bufferLabelImmediate: "Video Tampon Boyutu (0 (Anında)):",
            bufferLabelFrames: "Video Tampon Boyutu ({videoBufferSize} kare):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "Tam Renk 4:4:4",
            streamingModeDetails: "Turbo modu, tüm VNC mantığını devre dışı bırakır ve tüm kareleri geleneksel bir video kodlayıcı gibi kodlar.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU Kodlaması",
            jpegQualityLabel: "Temel Kalite: {jpegQuality}",
            paintOverJpegQualityLabel: "Üzerine Boyama Kalitesi: {paintOverJpegQuality}",
            paintoverCrfLabel: "Statik İyileştirme CRF ({crf}):",
            usePaintOverQualityLabel: "Statik İyileştirme Kullan",
        },
        audio: {
            title: "Ses Ayarları",
            bitrateLabel: "Ses Bit Hızı ({bitrate} kbps):",
            inputLabel: "Giriş (Mikrofon):",
            outputLabel: "Çıkış (Hoparlör):",
            outputNotSupported: "Çıkış aygıtı seçimi bu tarayıcı tarafından desteklenmiyor.",
            deviceErrorDefault: "Ses aygıtları listelenirken hata oluştu: {errorName}",
            deviceErrorPermission: "İzin reddedildi. Aygıtları seçmek için lütfen tarayıcı ayarlarında mikrofon erişimine izin verin.",
            deviceErrorNotFound: "Ses aygıtı bulunamadı.",
            defaultInputLabelFallback: "Giriş Aygıtı {index}",
            defaultOutputLabelFallback: "Çıkış Aygıtı {index}",
        },
        screen: {
            title: "Ekran Ayarları",
            presetLabel: "Ön Ayar:",
            resolutionPresetSelect: "-- Ön Ayar Seç --",
            widthLabel: "Genişlik:",
            heightLabel: "Yükseklik:",
            widthPlaceholder: "örneğin, 1920",
            heightPlaceholder: "örneğin, 1080",
            setManualButton: "Manuel Çözünürlüğü Ayarla",
            resetButton: "Pencereye Sıfırla",
            scaleLocallyLabel: "Yerel Olarak Ölçekle:",
            scaleLocallyOn: "AÇIK",
            scaleLocallyOff: "KAPALI",
            scaleLocallyTitleEnable: "Yerel Ölçeklendirmeyi Etkinleştir (En Boy Oranını Koru)",
            scaleLocallyTitleDisable: "Yerel Ölçeklendirmeyi Devre Dışı Bırak (Tam Çözünürlüğü Kullan)",
            uiScalingLabel: "Arayüz Ölçekleme:",
            hidpiLabel: "HiDPI (Piksel Mükemmelliği)",
            hidpiEnableTitle: "HiDPI'yi Etkinleştir (Piksel Mükemmelliği)",
            hidpiDisableTitle: "HiDPI'yi Devre Dışı Bırak (CSS Ölçeklendirme Kullan)",
            antiAliasingLabel: "Kenar Yumuşatma",
            antiAliasingEnableTitle: "Kenar yumuşatmayı etkinleştir (ölçeklemede pürüzsüzleştir)",
            antiAliasingDisableTitle: "Kenar yumuşatmayı devre dışı bırak (pikselli olmaya zorla)",
            useNativeCursorStylesLabel: "CSS imleçlerini kullan",
            useNativeCursorStylesEnableTitle: "CSS imleç işlemeyi kullan (Sistem imleçlerini değiştir)",
            useNativeCursorStylesDisableTitle: "Kanvas imleç işlemeyi kullan (Kanvasa çiz)",
            addScreenTitle: "İkinci bir ekran ekle",
            addScreenButton: "Ekran Ekle +",
        },
        stats: {
            title: "İstatistikler",
            cpuLabel: "CPU",
            gpuLabel: "GPU Kullanımı",
            sysMemLabel: "Sis Belleği",
            gpuMemLabel: "GPU Belleği",
            fpsLabel: "FPS",
            audioLabel: "Ses",
            tooltipCpu: "CPU Kullanımı: {value}%",
            tooltipGpu: "GPU Kullanımı: {value}%",
            tooltipSysMem: "Sistem Belleği: {used} / {total}",
            tooltipGpuMem: "GPU Belleği: {used} / {total}",
            tooltipFps: "İstemci FPS: {value}",
            tooltipAudio: "Ses Tamponları: {value}",
            tooltipMemoryNA: "N/A",
            bandwidthLabel: "Bant Genişliği",
            tooltipBandwidth: "Bant Genişliği: {value}mbps",
            latencyLabel: "Gecikme",
            tooltipLatency: "Gidiş-Dönüş Gecikmesi: {value}ms",
        },
        clipboard: {
            title: "Pano",
            label: "Sunucu Panosu:",
            placeholder: "Sunucudan pano içeriği...",
            binaryModeLabel: "Resim Desteği",
            binaryModeDetails: "Uzak oturuma ve oturumdan resim kopyalayıp yapıştırmaya izin verir.",
        },
        files: {
            title: "Dosyalar",
            uploadButton: "Dosya Yükle",
            uploadButtonTitle: "Uzak oturuma dosya yükle",
            downloadButtonTitle: "Dosyaları İndir",
        },
        gamepads: {
            title: "Oyun Kumandaları",
            noActivity: "Henüz oyun kumandası etkinliği algılanmadı...",
            touchEnableTitle: "Dokunmatik Oyun Kumandasını Etkinleştir",
            touchDisableTitle: "Dokunmatik Oyun Kumandasını Devre Dışı Bırak",
            touchActiveLabel: "Dokunmatik Kumanda: AÇIK",
            touchInactiveLabel: "Dokunmatik Kumanda: KAPALI",
            physicalHiddenForTouch: "Dokunmatik oyun kumandası etkinken fiziksel oyun kumandası ekranı gizlenir.",
            noActivityMobileOrEnableTouch: "Fiziksel oyun kumandası yok. Dokunmatik oyun kumandasını etkinleştirin veya bir denetleyici bağlayın."
        },
        apps: {
          title: "Uygulamalar",
          openButtonTitle: "Uygulamaları Yönet",
          openButton: "Uygulamaları Yönet"
        },
        sharing: {
            title: "Paylaşım"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Dizüstü)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Uygulama modalını kapat",
        loading: "Uygulamalar yükleniyor...",
        errorLoading: "Uygulama verileri yüklenemedi. Lütfen tekrar deneyin.",
        searchPlaceholder: "Uygulama ara...",
        noAppsFound: "Aramanızla eşleşen uygulama bulunamadı.",
        backButton: "Listeye geri dön",
        installButton: "Yükle",
        updateButton: "Güncelle",
        removeButton: "Kaldır",
        installingMessage: "Şunun için yükleme simüle ediliyor: {{appName}}",
        removingMessage: "Şunun için kaldırma simüle ediliyor: {{appName}}",
        updatingMessage: "Şunun için güncelleme simüle ediliyor: {{appName}}",
        installedBadge: "Yüklendi"
    },
    notifications: {
        closeButtonAlt: "{fileName} için bildirimi kapat",
        uploading: "Yükleniyor... {progress}%",
        uploadComplete: "Yükleme Tamamlandı",
        uploadFailed: "Yükleme Başarısız Oldu",
        errorPrefix: "Hata:",
        unknownError: "Bilinmeyen bir hata oluştu.",
        copiedTitle: "Kopyalandı: {label}",
        copiedMessage: "Bağlantı panoya kopyalandı: {textToCopy}",
        copyFailedTitle: "Kopyalama Başarısız: {label}",
        copyFailedError: "Bağlantı panoya kopyalanamadı.",
        scalingTitle: "Ölçekleme Güncellendi: Eylem Gerekli",
        scalingMessage: "Yeni ölçekleme uygulandı. Bazı uygulamalar veya masaüstü ortamları yeniden başlatma gerektirebilir.",
    },
    alerts: {
        invalidResolution: "Lütfen Genişlik ve Yükseklik için geçerli pozitif tam sayılar girin.",
    },
    byteUnits: ['Bayt', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bayt",
    filesModal: {
        closeAlt: "Dosya modalını kapat",
        iframeTitle: "İndirilebilir Dosyalar"
    }
};

// --- Italian Translations ---
const it = {
    selkiesLogoAlt: "Logo Selkies",
    toggleThemeTitle: "Cambia Tema",
    fullscreenTitle: "Entra in Schermo Intero",
    gamingModeTitle: "Modalità Gioco",
    trackpadModeTitle: "Modalità Trackpad",
    buttons: {
        videoStreamEnableTitle: "Abilita Stream Video",
        videoStreamDisableTitle: "Disabilita Stream Video",
        audioStreamEnableTitle: "Abilita Stream Audio",
        audioStreamDisableTitle: "Disabilita Stream Audio",
        microphoneEnableTitle: "Abilita Microfono",
        microphoneDisableTitle: "Disabilita Microfono",
        gamepadEnableTitle: "Abilita Input Gamepad",
        gamepadDisableTitle: "Disabilita Input Gamepad",
        virtualKeyboardButtonTitle: "Mostra Tastiera",
        h264FullColorEnableTitle: "Abilita H.264 Colore Completo",
        h264FullColorDisableTitle: "Disabilita H.264 Colore Completo",
        h264StreamingModeDisableTitle: "Disabilita Turbo",
        h264StreamingModeEnableTitle: "Abilita Turbo",
        useCpuEnableTitle: "Abilita Codifica CPU Forzata (Sovrascrive nvenc/vaapi)",
        useCpuDisableTitle: "Disabilita Codifica CPU Forzata (Sovrascrive nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Abilita Miglioramento Statico (Pulisce le porzioni statiche dello schermo)",
        usePaintOverQualityDisableTitle: "Disabilita Miglioramento Statico (Pulisce le porzioni statiche dello schermo)",
        binaryClipboardEnableTitle: "Abilita Appunti Immagine",
        binaryClipboardDisableTitle: "Disabilita Appunti Immagine",
    },
    sections: {
        video: {
            title: "Impostazioni Video",
            encoderLabel: "Encoder:",
            framerateLabel: "Frame al secondo ({framerate} FPS):",
            bitrateLabel: "Bitrate Video ({bitrate} Mbps):",
            bufferLabelImmediate: "Dimensione Buffer Video (0 (Immediato)):",
            bufferLabelFrames: "Dimensione Buffer Video ({videoBufferSize} frame):",
            crfLabel: "CRF Video ({crf}):",
            fullColorLabel: "Colore Completo 4:4:4",
            streamingModeDetails: "La modalità Turbo disabilita tutta la logica VNC e codifica tutti i fotogrammi come un codificatore video tradizionale.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "Codifica CPU",
            jpegQualityLabel: "Qualità di Base: {jpegQuality}",
            paintOverJpegQualityLabel: "Qualità Sovrapposizione: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF Miglioramento Statico ({crf}):",
            usePaintOverQualityLabel: "Usa Miglioramento Statico",
        },
        audio: {
            title: "Impostazioni Audio",
            bitrateLabel: "Bitrate Audio ({bitrate} kbps):",
            inputLabel: "Input (Microfono):",
            outputLabel: "Output (Altoparlante):",
            outputNotSupported: "La selezione del dispositivo di output non è supportata da questo browser.",
            deviceErrorDefault: "Errore nell'elencare i dispositivi audio: {errorName}",
            deviceErrorPermission: "Permesso negato. Consenti l'accesso al microfono nelle impostazioni del browser per selezionare i dispositivi.",
            deviceErrorNotFound: "Nessun dispositivo audio trovato.",
            defaultInputLabelFallback: "Dispositivo di Input {index}",
            defaultOutputLabelFallback: "Dispositivo di Output {index}",
        },
        screen: {
            title: "Impostazioni Schermo",
            presetLabel: "Preimpostazione:",
            resolutionPresetSelect: "-- Seleziona Preimpostazione --",
            widthLabel: "Larghezza:",
            heightLabel: "Altezza:",
            widthPlaceholder: "es. 1920",
            heightPlaceholder: "es. 1080",
            setManualButton: "Imposta Risoluzione Manuale",
            resetButton: "Ripristina a Finestra",
            scaleLocallyLabel: "Scala Localmente:",
            scaleLocallyOn: "ON",
            scaleLocallyOff: "OFF",
            scaleLocallyTitleEnable: "Abilita Scala Locale (Mantieni Proporzioni)",
            scaleLocallyTitleDisable: "Disabilita Scala Locale (Usa Risoluzione Esatta)",
            uiScalingLabel: "Scala Interfaccia:",
            hidpiLabel: "HiDPI (Pixel Perfect)",
            hidpiEnableTitle: "Abilita HiDPI (Pixel Perfect)",
            hidpiDisableTitle: "Disabilita HiDPI (Usa ridimensionamento CSS)",
            antiAliasingLabel: "Anti-aliasing",
            antiAliasingEnableTitle: "Abilita anti-aliasing (smussa durante il ridimensionamento)",
            antiAliasingDisableTitle: "Disabilita anti-aliasing (forza la pixelatura)",
            useNativeCursorStylesLabel: "Usa cursori CSS",
            useNativeCursorStylesEnableTitle: "Usa rendering del cursore CSS (Sostituisce i cursori di sistema)",
            useNativeCursorStylesDisableTitle: "Usa rendering del cursore su canvas (Disegna su canvas)",
            addScreenTitle: "Aggiungi un secondo schermo",
            addScreenButton: "Aggiungi Schermo +",
        },
        stats: {
            title: "Statistiche",
            cpuLabel: "CPU",
            gpuLabel: "Utilizzo GPU",
            sysMemLabel: "Mem Sistema",
            gpuMemLabel: "Mem GPU",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "Utilizzo CPU: {value}%",
            tooltipGpu: "Utilizzo GPU: {value}%",
            tooltipSysMem: "Memoria di Sistema: {used} / {total}",
            tooltipGpuMem: "Memoria GPU: {used} / {total}",
            tooltipFps: "FPS Client: {value}",
            tooltipAudio: "Buffer Audio: {value}",
            tooltipMemoryNA: "N/D",
            bandwidthLabel: "Larghezza di Banda",
            tooltipBandwidth: "Larghezza di Banda: {value}mbps",
            latencyLabel: "Latenza",
            tooltipLatency: "Latenza di Andata e Ritorno: {value}ms",
        },
        clipboard: {
            title: "Appunti",
            label: "Appunti del Server:",
            placeholder: "Contenuto degli appunti dal server...",
            binaryModeLabel: "Supporto Immagini",
            binaryModeDetails: "Consente di copiare e incollare immagini da e verso la sessione remota.",
        },
        files: {
            title: "File",
            uploadButton: "Carica File",
            uploadButtonTitle: "Carica file nella sessione remota",
            downloadButtonTitle: "Scarica File",
        },
        gamepads: {
            title: "Gamepad",
            noActivity: "Nessuna attività del gamepad ancora rilevata...",
            touchEnableTitle: "Abilita Gamepad Touch",
            touchDisableTitle: "Disabilita Gamepad Touch",
            touchActiveLabel: "Gamepad Touch: ON",
            touchInactiveLabel: "Gamepad Touch: OFF",
            physicalHiddenForTouch: "La visualizzazione dei gamepad fisici è nascosta mentre il gamepad touch è attivo.",
            noActivityMobileOrEnableTouch: "Nessun gamepad fisico. Abilita il gamepad touch o collega un controller."
        },
        apps: {
          title: "Applicazioni",
          openButtonTitle: "Gestisci Applicazioni",
          openButton: "Gestisci Applicazioni"
        },
        sharing: {
            title: "Condivisione"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Chiudi modale applicazioni",
        loading: "Caricamento applicazioni...",
        errorLoading: "Errore nel caricamento dei dati delle applicazioni. Riprova.",
        searchPlaceholder: "Cerca applicazioni...",
        noAppsFound: "Nessuna applicazione trovata corrispondente alla tua ricerca.",
        backButton: "Torna alla lista",
        installButton: "Installa",
        updateButton: "Aggiorna",
        removeButton: "Rimuovi",
        installingMessage: "Simulazione installazione per: {{appName}}",
        removingMessage: "Simulazione rimozione per: {{appName}}",
        updatingMessage: "Simulazione aggiornamento per: {{appName}}",
        installedBadge: "Installato"
    },
    notifications: {
        closeButtonAlt: "Chiudi notifica per {fileName}",
        uploading: "Caricamento... {progress}%",
        uploadComplete: "Caricamento Completato",
        uploadFailed: "Caricamento Fallito",
        errorPrefix: "Errore:",
        unknownError: "Si è verificato un errore sconosciuto.",
        copiedTitle: "Copiato: {label}",
        copiedMessage: "Link copiato negli appunti: {textToCopy}",
        copyFailedTitle: "Copia Fallita: {label}",
        copyFailedError: "Impossibile copiare il link negli appunti.",
        scalingTitle: "Scalabilità Aggiornata: Azione Richiesta",
        scalingMessage: "Nuova scalabilità applicata. Alcune applicazioni o ambienti desktop potrebbero richiedere un riavvio.",
    },
    alerts: {
        invalidResolution: "Inserisci numeri interi positivi validi per Larghezza e Altezza.",
    },
    byteUnits: ['Byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Byte",
    filesModal: {
        closeAlt: "Chiudi modale file",
        iframeTitle: "File Scaricabili"
    }
};

// --- Dutch Translations ---
const nl = {
    selkiesLogoAlt: "Selkies Logo",
    toggleThemeTitle: "Thema wisselen",
    fullscreenTitle: "Volledig scherm openen",
    gamingModeTitle: "Gaming Modus",
    trackpadModeTitle: "Trackpad-modus",
    buttons: {
        videoStreamEnableTitle: "Videostream inschakelen",
        videoStreamDisableTitle: "Videostream uitschakelen",
        audioStreamEnableTitle: "Audiostream inschakelen",
        audioStreamDisableTitle: "Audiostream uitschakelen",
        microphoneEnableTitle: "Microfoon inschakelen",
        microphoneDisableTitle: "Microfoon uitschakelen",
        gamepadEnableTitle: "Gamepad-invoer inschakelen",
        gamepadDisableTitle: "Gamepad-invoer uitschakelen",
        virtualKeyboardButtonTitle: "Toetsenbord Weergeven",
        h264FullColorEnableTitle: "H.264 Volledige Kleur inschakelen",
        h264FullColorDisableTitle: "H.264 Volledige Kleur uitschakelen",
        h264StreamingModeDisableTitle: "Turbo uitschakelen",
        h264StreamingModeEnableTitle: "Turbo inschakelen",
        useCpuEnableTitle: "Forceer CPU-codering inschakelen (Overschrijft nvenc/vaapi)",
        useCpuDisableTitle: "Forceer CPU-codering uitschakelen (Overschrijft nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Statische Verbetering inschakelen (Ruimt statische delen van het scherm op)",
        usePaintOverQualityDisableTitle: "Statische Verbetering uitschakelen (Ruimt statische delen van het scherm op)",
        binaryClipboardEnableTitle: "Afbeeldingenklembord inschakelen",
        binaryClipboardDisableTitle: "Afbeeldingenklembord uitschakelen",
    },
    sections: {
        video: {
            title: "Video-instellingen",
            encoderLabel: "Encoder:",
            framerateLabel: "Frames per seconde ({framerate} FPS):",
            bitrateLabel: "Video Bitrate ({bitrate} Mbps):",
            bufferLabelImmediate: "Video Buffergrootte (0 (Onmiddellijk)):",
            bufferLabelFrames: "Video Buffergrootte ({videoBufferSize} frames):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "Volledige Kleur 4:4:4",
            streamingModeDetails: "De Turbo-modus schakelt alle VNC-logica uit en codeert alle frames zoals een traditionele video-encoder.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU-codering",
            jpegQualityLabel: "Basiskwaliteit: {jpegQuality}",
            paintOverJpegQualityLabel: "Overschilderkwaliteit: {paintOverJpegQuality}",
            paintoverCrfLabel: "Statische Verbetering CRF ({crf}):",
            usePaintOverQualityLabel: "Gebruik Statische Verbetering",
        },
        audio: {
            title: "Audio-instellingen",
            bitrateLabel: "Audio Bitrate ({bitrate} kbps):",
            inputLabel: "Invoer (Microfoon):",
            outputLabel: "Uitvoer (Luidspreker):",
            outputNotSupported: "Selectie van uitvoerapparaat wordt niet ondersteund door deze browser.",
            deviceErrorDefault: "Fout bij het ophalen van audioapparaten: {errorName}",
            deviceErrorPermission: "Toestemming geweigerd. Sta microfoontoegang toe in browserinstellingen om apparaten te selecteren.",
            deviceErrorNotFound: "Geen audioapparaten gevonden.",
            defaultInputLabelFallback: "Invoerapparaat {index}",
            defaultOutputLabelFallback: "Uitvoerapparaat {index}",
        },
        screen: {
            title: "Scherminstellingen",
            presetLabel: "Voorinstelling:",
            resolutionPresetSelect: "-- Selecteer Voorinstelling --",
            widthLabel: "Breedte:",
            heightLabel: "Hoogte:",
            widthPlaceholder: "bijv. 1920",
            heightPlaceholder: "bijv. 1080",
            setManualButton: "Handmatige Resolutie Instellen",
            resetButton: "Terugzetten naar Venster",
            scaleLocallyLabel: "Lokaal Schalen:",
            scaleLocallyOn: "AAN",
            scaleLocallyOff: "UIT",
            scaleLocallyTitleEnable: "Lokaal Schalen Inschakelen (Beeldverhouding Behouden)",
            scaleLocallyTitleDisable: "Lokaal Schalen Uitschakelen (Exacte Resolutie Gebruiken)",
            uiScalingLabel: "UI Schalen:",
            hidpiLabel: "HiDPI (Pixel Perfect)",
            hidpiEnableTitle: "HiDPI inschakelen (Pixel Perfect)",
            hidpiDisableTitle: "HiDPI uitschakelen (CSS-schaling gebruiken)",
            antiAliasingLabel: "Randverzachting",
            antiAliasingEnableTitle: "Randverzachting inschakelen (vloeiend bij schalen)",
            antiAliasingDisableTitle: "Randverzachting uitschakelen (gepixeleerd forceren)",
            useNativeCursorStylesLabel: "CSS-cursors gebruiken",
            useNativeCursorStylesEnableTitle: "CSS-cursorweergave gebruiken (Vervangt systeemcursors)",
            useNativeCursorStylesDisableTitle: "Canvas-cursorweergave gebruiken (Tekenen op canvas)",
            addScreenTitle: "Een tweede scherm toevoegen",
            addScreenButton: "Scherm toevoegen +",
        },
        stats: {
            title: "Statistieken",
            cpuLabel: "CPU",
            gpuLabel: "GPU Gebruik",
            sysMemLabel: "Sys Geheugen",
            gpuMemLabel: "GPU Geheugen",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "CPU Gebruik: {value}%",
            tooltipGpu: "GPU Gebruik: {value}%",
            tooltipSysMem: "Systeemgeheugen: {used} / {total}",
            tooltipGpuMem: "GPU Geheugen: {used} / {total}",
            tooltipFps: "Client FPS: {value}",
            tooltipAudio: "Audio Buffers: {value}",
            tooltipMemoryNA: "N.v.t.",
            bandwidthLabel: "Bandbreedte",
            tooltipBandwidth: "Bandbreedte: {value}mbps",
            latencyLabel: "Latentie",
            tooltipLatency: "Round-trip Latentie: {value}ms",
        },
        clipboard: {
            title: "Klembord",
            label: "Server Klembord:",
            placeholder: "Klembord inhoud van server...",
            binaryModeLabel: "Afbeeldingsondersteuning",
            binaryModeDetails: "Staat het kopiëren en plakken van afbeeldingen van en naar de externe sessie toe.",
        },
        files: {
            title: "Bestanden",
            uploadButton: "Bestanden Uploaden",
            uploadButtonTitle: "Upload bestanden naar de externe sessie",
            downloadButtonTitle: "Bestanden Downloaden",
        },
        gamepads: {
            title: "Gamepads",
            noActivity: "Nog geen gamepad activiteit gedetecteerd...",
            touchEnableTitle: "Touch Gamepad inschakelen",
            touchDisableTitle: "Touch Gamepad uitschakelen",
            touchActiveLabel: "Touch Gamepad: AAN",
            touchInactiveLabel: "Touch Gamepad: UIT",
            physicalHiddenForTouch: "Weergave van fysieke gamepads is verborgen terwijl de touch gamepad actief is.",
            noActivityMobileOrEnableTouch: "Geen fysieke gamepads. Schakel de touch gamepad in of sluit een controller aan."
        },
        apps: {
          title: "Applicaties",
          openButtonTitle: "Applicaties beheren",
          openButton: "Applicaties beheren"
        },
        sharing: {
            title: "Delen"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Applicatiemodal sluiten",
        loading: "Applicaties laden...",
        errorLoading: "Fout bij het laden van applicatiegegevens. Probeer het opnieuw.",
        searchPlaceholder: "Zoek applicaties...",
        noAppsFound: "Geen applicaties gevonden die overeenkomen met uw zoekopdracht.",
        backButton: "Terug naar lijst",
        installButton: "Installeren",
        updateButton: "Bijwerken",
        removeButton: "Verwijderen",
        installingMessage: "Simulatie van installatie voor: {{appName}}",
        removingMessage: "Simulatie van verwijdering voor: {{appName}}",
        updatingMessage: "Simulatie van update voor: {{appName}}",
        installedBadge: "Geïnstalleerd"
    },
    notifications: {
        closeButtonAlt: "Melding sluiten voor {fileName}",
        uploading: "Uploaden... {progress}%",
        uploadComplete: "Upload Voltooid",
        uploadFailed: "Upload Mislukt",
        errorPrefix: "Fout:",
        unknownError: "Er is een onbekende fout opgetreden.",
        copiedTitle: "Gekopieerd: {label}",
        copiedMessage: "Link gekopieerd naar klembord: {textToCopy}",
        copyFailedTitle: "Kopiëren Mislukt: {label}",
        copyFailedError: "Kon link niet naar klembord kopiëren.",
        scalingTitle: "Schalen bijgewerkt: Actie vereist",
        scalingMessage: "Nieuwe schaling toegepast. Sommige applicaties of desktopomgevingen moeten mogelijk opnieuw worden opgestart.",
    },
    alerts: {
        invalidResolution: "Voer geldige positieve gehele getallen in voor Breedte en Hoogte.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Bestandsmodal sluiten",
        iframeTitle: "Downloadbare bestanden"
    }
};

// --- Arabic Translations ---
const ar = {
    selkiesLogoAlt: "شعار Selkies",
    toggleThemeTitle: "تبديل السمة",
    fullscreenTitle: "الدخول في وضع ملء الشاشة",
    gamingModeTitle: "وضع الألعاب",
    trackpadModeTitle: "وضع لوحة اللمس",
    buttons: {
        videoStreamEnableTitle: "تمكين بث الفيديو",
        videoStreamDisableTitle: "تعطيل بث الفيديو",
        audioStreamEnableTitle: "تمكين بث الصوت",
        audioStreamDisableTitle: "تعطيل بث الصوت",
        microphoneEnableTitle: "تمكين الميكروفون",
        microphoneDisableTitle: "تعطيل الميكروفون",
        gamepadEnableTitle: "تمكين إدخال لوحة الألعاب",
        gamepadDisableTitle: "تعطيل إدخال لوحة الألعاب",
        virtualKeyboardButtonTitle: "إظهار لوحة المفاتيح",
        h264FullColorEnableTitle: "تمكين H.264 ألوان كاملة",
        h264FullColorDisableTitle: "تعطيل H.264 ألوان كاملة",
        h264StreamingModeDisableTitle: "تعطيل وضع التوربو",
        h264StreamingModeEnableTitle: "تمكين وضع التوربو",
        useCpuEnableTitle: "تمكين فرض ترميز CPU (يتجاوز nvenc/vaapi)",
        useCpuDisableTitle: "تعطيل فرض ترميز CPU (يتجاوز nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "تمكين تحسين الصورة الثابتة (ينظف الأجزاء الثابتة من الشاشة)",
        usePaintOverQualityDisableTitle: "تعطيل تحسين الصورة الثابتة (ينظف الأجزاء الثابتة من الشاشة)",
        binaryClipboardEnableTitle: "تمكين حافظة الصور",
        binaryClipboardDisableTitle: "تعطيل حافظة الصور",
    },
    sections: {
        video: {
            title: "إعدادات الفيديو",
            encoderLabel: "المُرمّز:",
            framerateLabel: "إطارات في الثانية ({framerate} FPS):",
            bitrateLabel: "معدل بت الفيديو ({bitrate} Mbps):",
            bufferLabelImmediate: "حجم مخزن الفيديو المؤقت (0 (فوري)):",
            bufferLabelFrames: "حجم مخزن الفيديو المؤقت ({videoBufferSize} إطارات):",
            crfLabel: "CRF الفيديو ({crf}):",
            fullColorLabel: "ألوان كاملة 4:4:4",
            streamingModeDetails: "يعطل وضع التوربو كل منطق VNC ويقوم بترميز جميع الإطارات مثل مرمّز الفيديو التقليدي.",
            streamingModeLabel: "توربو",
            useCpuLabel: "ترميز CPU",
            jpegQualityLabel: "الجودة الأساسية: {jpegQuality}",
            paintOverJpegQualityLabel: "جودة الرسم فوق الصورة: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF تحسين الصورة الثابتة ({crf}):",
            usePaintOverQualityLabel: "استخدام تحسين الصورة الثابتة",
        },
        audio: {
            title: "إعدادات الصوت",
            bitrateLabel: "معدل بت الصوت ({bitrate} kbps):",
            inputLabel: "الإدخال (الميكروفون):",
            outputLabel: "الإخراج (مكبر الصوت):",
            outputNotSupported: "اختيار جهاز الإخراج غير مدعوم بواسطة هذا المتصفح.",
            deviceErrorDefault: "خطأ في سرد أجهزة الصوت: {errorName}",
            deviceErrorPermission: "تم رفض الإذن. يرجى السماح بالوصول إلى الميكروفون في إعدادات المتصفح لتحديد الأجهزة.",
            deviceErrorNotFound: "لم يتم العثور على أجهزة صوت.",
            defaultInputLabelFallback: "جهاز الإدخال {index}",
            defaultOutputLabelFallback: "جهاز الإخراج {index}",
        },
        screen: {
            title: "إعدادات الشاشة",
            presetLabel: "إعداد مسبق:",
            resolutionPresetSelect: "-- تحديد إعداد مسبق --",
            widthLabel: "العرض:",
            heightLabel: "الارتفاع:",
            widthPlaceholder: "مثال، 1920",
            heightPlaceholder: "مثال، 1080",
            setManualButton: "تعيين دقة يدوية",
            resetButton: "إعادة التعيين إلى النافذة",
            scaleLocallyLabel: "تغيير الحجم محليًا:",
            scaleLocallyOn: "تشغيل",
            scaleLocallyOff: "إيقاف",
            scaleLocallyTitleEnable: "تمكين تغيير الحجم المحلي (الحفاظ على نسبة العرض إلى الارتفاع)",
            scaleLocallyTitleDisable: "تعطيل تغيير الحجم المحلي (استخدام الدقة الدقيقة)",
            uiScalingLabel: "مقياس واجهة المستخدم:",
            hidpiLabel: "HiDPI (دقة بكسل مثالية)",
            hidpiEnableTitle: "تمكين HiDPI (دقة بكسل مثالية)",
            hidpiDisableTitle: "تعطيل HiDPI (استخدام تحجيم CSS)",
            antiAliasingLabel: "تنعيم الحواف",
            antiAliasingEnableTitle: "تمكين تنعيم الحواف (سلس عند التكبير)",
            antiAliasingDisableTitle: "تعطيل تنعيم الحواف (فرض البيكسلات)",
            useNativeCursorStylesLabel: "استخدام مؤشرات CSS",
            useNativeCursorStylesEnableTitle: "استخدام عرض مؤشر CSS (استبدال مؤشرات النظام)",
            useNativeCursorStylesDisableTitle: "استخدام عرض مؤشر اللوحة (الرسم على اللوحة)",
            addScreenTitle: "إضافة شاشة ثانية",
            addScreenButton: "إضافة شاشة +",
        },
        stats: {
            title: "الإحصائيات",
            cpuLabel: "CPU",
            gpuLabel: "استخدام GPU",
            sysMemLabel: "ذاكرة النظام",
            gpuMemLabel: "ذاكرة GPU",
            fpsLabel: "FPS",
            audioLabel: "الصوت",
            tooltipCpu: "استخدام CPU: {value}%",
            tooltipGpu: "استخدام GPU: {value}%",
            tooltipSysMem: "ذاكرة النظام: {used} / {total}",
            tooltipGpuMem: "ذاكرة GPU: {used} / {total}",
            tooltipFps: "FPS العميل: {value}",
            tooltipAudio: "مخازن الصوت المؤقتة: {value}",
            tooltipMemoryNA: "غير متاح",
            bandwidthLabel: "عرض النطاق",
            tooltipBandwidth: "عرض النطاق: {value}mbps",
            latencyLabel: "الكمون",
            tooltipLatency: "كمون الرحلة ذهابًا وإيابًا: {value}ms",
        },
        clipboard: {
            title: "الحافظة",
            label: "حافظة الخادم:",
            placeholder: "محتوى الحافظة من الخادم...",
            binaryModeLabel: "دعم الصور",
            binaryModeDetails: "يسمح بنسخ ولصق الصور من وإلى الجلسة البعيدة.",
        },
        files: {
            title: "الملفات",
            uploadButton: "تحميل الملفات",
            uploadButtonTitle: "تحميل الملفات إلى الجلسة البعيدة",
            downloadButtonTitle: "تحميل الملفات",
        },
        gamepads: {
            title: "لوحات الألعاب",
            noActivity: "لم يتم اكتشاف أي نشاط للوحة الألعاب بعد...",
            touchEnableTitle: "تمكين لوحة ألعاب اللمس",
            touchDisableTitle: "تعطيل لوحة ألعاب اللمس",
            touchActiveLabel: "لوحة ألعاب اللمس: تشغيل",
            touchInactiveLabel: "لوحة ألعاب اللمس: إيقاف",
            physicalHiddenForTouch: "يتم إخفاء عرض لوحة الألعاب الفعلية أثناء تنشيط لوحة ألعاب اللمس.",
            noActivityMobileOrEnableTouch: "لا توجد لوحات ألعاب فعلية. قم بتمكين لوحة ألعاب اللمس أو قم بتوصيل وحدة تحكم."
        },
        apps: { // New section for "Apps"
          title: "التطبيقات",
          openButtonTitle: "إدارة التطبيقات",
          openButton: "إدارة التطبيقات"
        },
        sharing: {
            title: "المشاركة"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 × 1080 (FHD)",
        "1280x720": "1280 × 720 (HD)",
        "1366x768": "1366 × 768 (لابتوب)",
        "1920x1200": "1920 × 1200 (16:10)",
        "2560x1440": "2560 × 1440 (QHD)",
        "3840x2160": "3840 × 2160 (4K UHD)",
        "1024x768": "1024 × 768 (XGA 4:3)",
        "800x600": "800 × 600 (SVGA 4:3)",
        "640x480": "640 × 480 (VGA 4:3)",
        "320x240": "320 × 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "إغلاق نافذة التطبيقات",
        loading: "جارٍ تحميل التطبيقات...",
        errorLoading: "فشل تحميل بيانات التطبيقات. يرجى المحاولة مرة أخرى.",
        searchPlaceholder: "البحث في التطبيقات...",
        noAppsFound: "لم يتم العثور على تطبيقات تطابق بحثك.",
        backButton: "العودة إلى القائمة",
        installButton: "تثبيت",
        updateButton: "تحديث",
        removeButton: "إزالة",
        installingMessage: "محاكاة التثبيت لـ: {{appName}}",
        removingMessage: "محاكاة الإزالة لـ: {{appName}}",
        updatingMessage: "محاكاة التحديث لـ: {{appName}}",
        installedBadge: "مثبت"
    },
    notifications: {
        closeButtonAlt: "إغلاق الإشعار لـ {fileName}",
        uploading: "جارٍ التحميل... {progress}%",
        uploadComplete: "اكتمل التحميل",
        uploadFailed: "فشل التحميل",
        errorPrefix: "خطأ:",
        unknownError: "حدث خطأ غير معروف.",
        copiedTitle: "تم النسخ: {label}",
        copiedMessage: "تم نسخ الرابط إلى الحافظة: {textToCopy}",
        copyFailedTitle: "فشل النسخ: {label}",
        copyFailedError: "تعذر نسخ الرابط إلى الحافظة.",
        scalingTitle: "تم تحديث القياس: الإجراء مطلوب",
        scalingMessage: "تم تطبيق القياس الجديد. قد تتطلب بعض التطبيقات أو بيئات سطح المكتب إعادة التشغيل.",
    },
    alerts: {
        invalidResolution: "الرجاء إدخال أعداد صحيحة موجبة صالحة للعرض والارتفاع.",
    },
    byteUnits: ['بايت', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 بايت",
    filesModal: {
        closeAlt: "إغلاق نافذة الملفات",
        iframeTitle: "ملفات قابلة للتحميل"
    }
};

// --- Korean Translations ---
const ko = {
    selkiesLogoAlt: "Selkies 로고",
    toggleThemeTitle: "테마 전환",
    fullscreenTitle: "전체 화면 시작",
    gamingModeTitle: "게임 모드",
    trackpadModeTitle: "트랙패드 모드",
    buttons: {
        videoStreamEnableTitle: "비디오 스트림 활성화",
        videoStreamDisableTitle: "비디오 스트림 비활성화",
        audioStreamEnableTitle: "오디오 스트림 활성화",
        audioStreamDisableTitle: "오디오 스트림 비활성화",
        microphoneEnableTitle: "마이크 활성화",
        microphoneDisableTitle: "마이크 비활성화",
        gamepadEnableTitle: "게임패드 입력 활성화",
        gamepadDisableTitle: "게임패드 입력 비활성화",
        virtualKeyboardButtonTitle: "키보드 표시",
        h264FullColorEnableTitle: "H.264 전체 색상 활성화",
        h264FullColorDisableTitle: "H.264 전체 색상 비활성화",
        h264StreamingModeDisableTitle: "터보 비활성화",
        h264StreamingModeEnableTitle: "터보 활성화",
        useCpuEnableTitle: "강제 CPU 인코딩 활성화 (nvenc/vaapi 재정의)",
        useCpuDisableTitle: "강제 CPU 인코딩 비활성화 (nvenc/vaapi 재정의)",
        usePaintOverQualityEnableTitle: "정적 영역 개선 활성화 (화면의 정적 부분을 정리합니다)",
        usePaintOverQualityDisableTitle: "정적 영역 개선 비활성화 (화면의 정적 부분을 정리합니다)",
        binaryClipboardEnableTitle: "이미지 클립보드 활성화",
        binaryClipboardDisableTitle: "이미지 클립보드 비활성화",
    },
    sections: {
        video: {
            title: "비디오 설정",
            encoderLabel: "인코더:",
            framerateLabel: "초당 프레임 ({framerate} FPS):",
            bitrateLabel: "비디오 비트 전송률 ({bitrate} Mbps):",
            bufferLabelImmediate: "비디오 버퍼 크기 (0 (즉시)):",
            bufferLabelFrames: "비디오 버퍼 크기 ({videoBufferSize} 프레임):",
            crfLabel: "비디오 CRF ({crf}):",
            fullColorLabel: "전체 색상 4:4:4",
            streamingModeDetails: "터보 모드는 모든 VNC 로직을 비활성화하고 모든 프레임을 기존 비디오 인코더처럼 인코딩합니다.",
            streamingModeLabel: "터보",
            useCpuLabel: "CPU 인코딩",
            jpegQualityLabel: "기본 품질: {jpegQuality}",
            paintOverJpegQualityLabel: "덧칠 품질: {paintOverJpegQuality}",
            paintoverCrfLabel: "정적 영역 개선 CRF ({crf}):",
            usePaintOverQualityLabel: "정적 영역 개선 사용",
        },
        audio: {
            title: "오디오 설정",
            bitrateLabel: "오디오 비트 전송률 ({bitrate} kbps):",
            inputLabel: "입력 (마이크):",
            outputLabel: "출력 (스피커):",
            outputNotSupported: "이 브라우저에서는 출력 장치 선택을 지원하지 않습니다.",
            deviceErrorDefault: "오디오 장치 목록 오류: {errorName}",
            deviceErrorPermission: "권한이 거부되었습니다. 장치를 선택하려면 브라우저 설정에서 마이크 액세스를 허용하십시오.",
            deviceErrorNotFound: "오디오 장치를 찾을 수 없습니다.",
            defaultInputLabelFallback: "입력 장치 {index}",
            defaultOutputLabelFallback: "출력 장치 {index}",
        },
        screen: {
            title: "화면 설정",
            presetLabel: "프리셋:",
            resolutionPresetSelect: "-- 프리셋 선택 --",
            widthLabel: "너비:",
            heightLabel: "높이:",
            widthPlaceholder: "예: 1920",
            heightPlaceholder: "예: 1080",
            setManualButton: "수동 해상도 설정",
            resetButton: "창으로 재설정",
            scaleLocallyLabel: "로컬 스케일링:",
            scaleLocallyOn: "켜짐",
            scaleLocallyOff: "꺼짐",
            scaleLocallyTitleEnable: "로컬 스케일링 활성화 (종횡비 유지)",
            scaleLocallyTitleDisable: "로컬 스케일링 비활성화 (정확한 해상도 사용)",
            uiScalingLabel: "UI 스케일링:",
            hidpiLabel: "HiDPI (픽셀 퍼펙트)",
            hidpiEnableTitle: "HiDPI 활성화 (픽셀 퍼펙트)",
            hidpiDisableTitle: "HiDPI 비활성화 (CSS 스케일링 사용)",
            antiAliasingLabel: "안티에일리어싱",
            antiAliasingEnableTitle: "안티에일리어싱 활성화 (확대/축소 시 부드럽게)",
            antiAliasingDisableTitle: "안티에일리어싱 비활성화 (픽셀화 강제)",
            useNativeCursorStylesLabel: "CSS 커서 사용",
            useNativeCursorStylesEnableTitle: "CSS 커서 렌더링 사용 (시스템 커서 대체)",
            useNativeCursorStylesDisableTitle: "캔버스 커서 렌더링 사용 (캔버스에 그리기)",
            addScreenTitle: "두 번째 화면 추가",
            addScreenButton: "화면 추가 +",
        },
        stats: {
            title: "통계",
            cpuLabel: "CPU",
            gpuLabel: "GPU 사용량",
            sysMemLabel: "시스템 메모리",
            gpuMemLabel: "GPU 메모리",
            fpsLabel: "FPS",
            audioLabel: "오디오",
            tooltipCpu: "CPU 사용량: {value}%",
            tooltipGpu: "GPU 사용량: {value}%",
            tooltipSysMem: "시스템 메모리: {used} / {total}",
            tooltipGpuMem: "GPU 메모리: {used} / {total}",
            tooltipFps: "클라이언트 FPS: {value}",
            tooltipAudio: "오디오 버퍼: {value}",
            tooltipMemoryNA: "해당 없음",
            bandwidthLabel: "대역폭",
            tooltipBandwidth: "대역폭: {value}mbps",
            latencyLabel: "지연 시간",
            tooltipLatency: "왕복 지연 시간: {value}ms",
        },
        clipboard: {
            title: "클립보드",
            label: "서버 클립보드:",
            placeholder: "서버의 클립보드 내용...",
            binaryModeLabel: "이미지 지원",
            binaryModeDetails: "원격 세션에서 이미지를 복사하고 붙여넣을 수 있습니다.",
        },
        files: {
            title: "파일",
            uploadButton: "파일 업로드",
            uploadButtonTitle: "원격 세션에 파일 업로드",
            downloadButtonTitle: "파일 다운로드",
        },
        gamepads: {
            title: "게임패드",
            noActivity: "아직 게임패드 활동이 감지되지 않았습니다...",
            touchEnableTitle: "터치 게임패드 활성화",
            touchDisableTitle: "터치 게임패드 비활성화",
            touchActiveLabel: "터치 게임패드: 켜짐",
            touchInactiveLabel: "터치 게임패드: 꺼짐",
            physicalHiddenForTouch: "터치 게임패드가 활성화되어 있는 동안에는 물리적 게임패드 표시가 숨겨집니다.",
            noActivityMobileOrEnableTouch: "물리적 게임패드가 없습니다. 터치 게임패드를 활성화하거나 컨트롤러를 연결하십시오."
        },
        apps: {
          title: "앱",
          openButtonTitle: "앱 관리",
          openButton: "앱 관리"
        },
        sharing: {
            title: "공유"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (노트북)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "앱 모달 닫기",
        loading: "앱 로드 중...",
        errorLoading: "앱 데이터 로드 실패. 다시 시도하십시오.",
        searchPlaceholder: "앱 검색...",
        noAppsFound: "검색과 일치하는 앱을 찾을 수 없습니다.",
        backButton: "목록으로 돌아가기",
        installButton: "설치",
        updateButton: "업데이트",
        removeButton: "제거",
        installingMessage: "{{appName}} 설치 시뮬레이션 중",
        removingMessage: "{{appName}} 제거 시뮬레이션 중",
        updatingMessage: "{{appName}} 업데이트 시뮬레이션 중",
        installedBadge: "설치됨"
    },
    notifications: {
        closeButtonAlt: "{fileName} 알림 닫기",
        uploading: "업로드 중... {progress}%",
        uploadComplete: "업로드 완료",
        uploadFailed: "업로드 실패",
        errorPrefix: "오류:",
        unknownError: "알 수 없는 오류가 발생했습니다.",
        copiedTitle: "복사됨: {label}",
        copiedMessage: "링크가 클립보드에 복사되었습니다: {textToCopy}",
        copyFailedTitle: "복사 실패: {label}",
        copyFailedError: "링크를 클립보드에 복사할 수 없습니다.",
        scalingTitle: "확장/축소 업데이트됨: 작업 필요",
        scalingMessage: "새로운 스케일링이 적용되었습니다. 일부 응용 프로그램이나 데스크톱 환경은 재시작이 필요할 수 있습니다.",
    },
    alerts: {
        invalidResolution: "너비와 높이에 유효한 양의 정수를 입력하십시오.",
    },
    byteUnits: ['바이트', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 바이트",
    filesModal: {
        closeAlt: "파일 모달 닫기",
        iframeTitle: "다운로드 가능한 파일"
    }
};

// --- Japanese Translations ---
const ja = {
    selkiesLogoAlt: "Selkies ロゴ",
    toggleThemeTitle: "テーマを切り替え",
    fullscreenTitle: "フルスクリーンに入る",
    gamingModeTitle: "ゲームモード",
    trackpadModeTitle: "トラックパッドモード",
    buttons: {
        videoStreamEnableTitle: "ビデオストリームを有効にする",
        videoStreamDisableTitle: "ビデオストリームを無効にする",
        audioStreamEnableTitle: "オーディオストリームを有効にする",
        audioStreamDisableTitle: "オーディオストリームを無効にする",
        microphoneEnableTitle: "マイクを有効にする",
        microphoneDisableTitle: "マイクを無効にする",
        gamepadEnableTitle: "ゲームパッド入力を有効にする",
        gamepadDisableTitle: "ゲームパッド入力を無効にする",
        virtualKeyboardButtonTitle: "キーボードを表示",
        h264FullColorEnableTitle: "H.264 フルカラーを有効にする",
        h264FullColorDisableTitle: "H.264 フルカラーを無効にする",
        h264StreamingModeDisableTitle: "ターボを無効にする",
        h264StreamingModeEnableTitle: "ターボを有効にする",
        useCpuEnableTitle: "強制 CPU エンコーディングを有効にする (nvenc/vaapi を上書き)",
        useCpuDisableTitle: "強制 CPU エンコーディングを無効にする (nvenc/vaapi を上書き)",
        usePaintOverQualityEnableTitle: "静止領域の補正を有効にする (画面の静的な部分をクリーンアップします)",
        usePaintOverQualityDisableTitle: "静止領域の補正を無効にする (画面の静的な部分をクリーンアップします)",
        binaryClipboardEnableTitle: "画像クリップボードを有効にする",
        binaryClipboardDisableTitle: "画像クリップボードを無効にする",
    },
    sections: {
        video: {
            title: "ビデオ設定",
            encoderLabel: "エンコーダー:",
            framerateLabel: "フレーム/秒 ({framerate} FPS):",
            bitrateLabel: "ビデオビットレート ({bitrate} Mbps):",
            bufferLabelImmediate: "ビデオバッファサイズ (0 (即時)):",
            bufferLabelFrames: "ビデオバッファサイズ ({videoBufferSize} フレーム):",
            crfLabel: "ビデオ CRF ({crf}):",
            fullColorLabel: "フルカラー 4:4:4",
            streamingModeDetails: "ターボモードはすべてのVNCロジックを無効にし、すべてのフレームを従来のビデオエンコーダーのようにエンコードします。",
            streamingModeLabel: "ターボ",
            useCpuLabel: "CPU エンコーディング",
            jpegQualityLabel: "基本品質: {jpegQuality}",
            paintOverJpegQualityLabel: "ペイントオーバー品質: {paintOverJpegQuality}",
            paintoverCrfLabel: "静止領域補正 CRF ({crf}):",
            usePaintOverQualityLabel: "静止領域の補正を使用",
        },
        audio: {
            title: "オーディオ設定",
            bitrateLabel: "オーディオビットレート ({bitrate} kbps):",
            inputLabel: "入力 (マイク):",
            outputLabel: "出力 (スピーカー):",
            outputNotSupported: "このブラウザでは出力デバイスの選択はサポートされていません。",
            deviceErrorDefault: "オーディオデバイスのリスト表示エラー: {errorName}",
            deviceErrorPermission: "権限が拒否されました。デバイスを選択するには、ブラウザ設定でマイクへのアクセスを許可してください。",
            deviceErrorNotFound: "オーディオデバイスが見つかりません。",
            defaultInputLabelFallback: "入力デバイス {index}",
            defaultOutputLabelFallback: "出力デバイス {index}",
        },
        screen: {
            title: "画面設定",
            presetLabel: "プリセット:",
            resolutionPresetSelect: "-- プリセットを選択 --",
            widthLabel: "幅:",
            heightLabel: "高さ:",
            widthPlaceholder: "例: 1920",
            heightPlaceholder: "例: 1080",
            setManualButton: "手動解像度を設定",
            resetButton: "ウィンドウにリセット",
            scaleLocallyLabel: "ローカルでスケーリング:",
            scaleLocallyOn: "オン",
            scaleLocallyOff: "オフ",
            scaleLocallyTitleEnable: "ローカルスケーリングを有効にする (アスペクト比を維持)",
            scaleLocallyTitleDisable: "ローカルスケーリングを無効にする (正確な解像度を使用)",
            uiScalingLabel: "UI スケーリング:",
            hidpiLabel: "HiDPI (ピクセルパーフェクト)",
            hidpiEnableTitle: "HiDPI を有効にする (ピクセルパーフェクト)",
            hidpiDisableTitle: "HiDPI を無効にする (CSS スケーリングを使用)",
            antiAliasingLabel: "アンチエイリアシング",
            antiAliasingEnableTitle: "アンチエイリアシングを有効にする (スケーリング時に滑らかに)",
            antiAliasingDisableTitle: "アンチエイリアシングを無効にする (ピクセル化を強制)",
            useNativeCursorStylesLabel: "CSS カーソルを使用",
            useNativeCursorStylesEnableTitle: "CSS カーソルレンダリングを使用 (システムカーソルを置換)",
            useNativeCursorStylesDisableTitle: "キャンバスカーソルレンダリングを使用 (キャンバスに描画)",
            addScreenTitle: "2番目の画面を追加",
            addScreenButton: "画面を追加 +",
        },
        stats: {
            title: "統計",
            cpuLabel: "CPU",
            gpuLabel: "GPU 使用率",
            sysMemLabel: "システムメモリ",
            gpuMemLabel: "GPU メモリ",
            fpsLabel: "FPS",
            audioLabel: "オーディオ",
            tooltipCpu: "CPU 使用率: {value}%",
            tooltipGpu: "GPU 使用率: {value}%",
            tooltipSysMem: "システムメモリ: {used} / {total}",
            tooltipGpuMem: "GPU メモリ: {used} / {total}",
            tooltipFps: "クライアント FPS: {value}",
            tooltipAudio: "オーディオバッファ: {value}",
            tooltipMemoryNA: "N/A",
            bandwidthLabel: "帯域幅",
            tooltipBandwidth: "帯域幅: {value}mbps",
            latencyLabel: "遅延",
            tooltipLatency: "ラウンドトリップ遅延: {value}ms",
        },
        clipboard: {
            title: "クリップボード",
            label: "サーバークリップボード:",
            placeholder: "サーバーからのクリップボードの内容...",
            binaryModeLabel: "画像サポート",
            binaryModeDetails: "リモートセッションとの間で画像をコピー＆ペーストできます。",
        },
        files: {
            title: "ファイル",
            uploadButton: "ファイルをアップロード",
            uploadButtonTitle: "リモートセッションにファイルをアップロード",
            downloadButtonTitle: "ファイルをダウンロード",
        },
        gamepads: {
            title: "ゲームパッド",
            noActivity: "まだゲームパッドのアクティビティが検出されていません...",
            touchEnableTitle: "タッチゲームパッドを有効にする",
            touchDisableTitle: "タッチゲームパッドを無効にする",
            touchActiveLabel: "タッチゲームパッド: オン",
            touchInactiveLabel: "タッチゲームパッド: オフ",
            physicalHiddenForTouch: "タッチゲームパッドがアクティブな間、物理ゲームパッドの表示は非表示になります。",
            noActivityMobileOrEnableTouch: "物理ゲームパッドがありません。タッチゲームパッドを有効にするか、コントローラーを接続してください。"
        },
        apps: {
          title: "アプリ",
          openButtonTitle: "アプリを管理",
          openButton: "アプリを管理"
        },
        sharing: {
            title: "共有"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (ラップトップ)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "アプリモーダルを閉じる",
        loading: "アプリを読み込み中...",
        errorLoading: "アプリデータの読み込みに失敗しました。もう一度お試しください。",
        searchPlaceholder: "アプリを検索...",
        noAppsFound: "検索に一致するアプリが見つかりません。",
        backButton: "リストに戻る",
        installButton: "インストール",
        updateButton: "更新",
        removeButton: "削除",
        installingMessage: "{{appName}} のインストールをシミュレートしています",
        removingMessage: "{{appName}} の削除をシミュレートしています",
        updatingMessage: "{{appName}} の更新をシミュレートしています",
        installedBadge: "インストール済み"
    },
    notifications: {
        closeButtonAlt: "{fileName} の通知を閉じる",
        uploading: "アップロード中... {progress}%",
        uploadComplete: "アップロード完了",
        uploadFailed: "アップロード失敗",
        errorPrefix: "エラー:",
        unknownError: "不明なエラーが発生しました。",
        copiedTitle: "コピーしました: {label}",
        copiedMessage: "リンクをクリップボードにコピーしました: {textToCopy}",
        copyFailedTitle: "コピーに失敗しました: {label}",
        copyFailedError: "リンクをクリップボードにコピーできませんでした。",
        scalingTitle: "スケーリング更新：アクションが必要です",
        scalingMessage: "新しいスケーリングが適用されました。一部のアプリケーションまたはデスクトップ環境では、再起動が必要な場合があります。",
    },
    alerts: {
        invalidResolution: "幅と高さに有効な正の整数を入力してください。",
    },
    byteUnits: ['バイト', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 バイト",
    filesModal: {
        closeAlt: "ファイルモーダルを閉じる",
        iframeTitle: "ダウンロード可能なファイル"
    }
};

// --- Vietnamese Translations ---
const vi = {
    selkiesLogoAlt: "Logo Selkies",
    toggleThemeTitle: "Chuyển đổi Chủ đề",
    fullscreenTitle: "Vào Toàn màn hình",
    gamingModeTitle: "Chế độ Chơi game",
    trackpadModeTitle: "Chế độ Bàn di chuột",
    buttons: {
        videoStreamEnableTitle: "Bật Luồng Video",
        videoStreamDisableTitle: "Tắt Luồng Video",
        audioStreamEnableTitle: "Bật Luồng Âm thanh",
        audioStreamDisableTitle: "Tắt Luồng Âm thanh",
        microphoneEnableTitle: "Bật Micro",
        microphoneDisableTitle: "Tắt Micro",
        gamepadEnableTitle: "Bật Đầu vào Tay cầm chơi game",
        gamepadDisableTitle: "Tắt Đầu vào Tay cầm chơi game",
        virtualKeyboardButtonTitle: "Hiển thị Bàn phím",
        h264FullColorEnableTitle: "Bật H.264 Đầy đủ Màu sắc",
        h264FullColorDisableTitle: "Tắt H.264 Đầy đủ Màu sắc",
        h264StreamingModeDisableTitle: "Tắt chế độ Turbo",
        h264StreamingModeEnableTitle: "Bật chế độ Turbo",
        useCpuEnableTitle: "Bật Mã hóa CPU Bắt buộc (Ghi đè nvenc/vaapi)",
        useCpuDisableTitle: "Tắt Mã hóa CPU Bắt buộc (Ghi đè nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Bật Cải thiện vùng tĩnh (Dọn dẹp các phần tĩnh của màn hình)",
        usePaintOverQualityDisableTitle: "Tắt Cải thiện vùng tĩnh (Dọn dẹp các phần tĩnh của màn hình)",
        binaryClipboardEnableTitle: "Bật Bộ nhớ tạm cho Hình ảnh",
        binaryClipboardDisableTitle: "Tắt Bộ nhớ tạm cho Hình ảnh",
    },
    sections: {
        video: {
            title: "Cài đặt Video",
            encoderLabel: "Bộ mã hóa:",
            framerateLabel: "Khung hình mỗi giây ({framerate} FPS):",
            bitrateLabel: "Tốc độ bit Video ({bitrate} Mbps):",
            bufferLabelImmediate: "Kích thước Bộ đệm Video (0 (Ngay lập tức)):",
            bufferLabelFrames: "Kích thước Bộ đệm Video ({videoBufferSize} khung hình):",
            crfLabel: "CRF Video ({crf}):",
            fullColorLabel: "Đầy đủ Màu sắc 4:4:4",
            streamingModeDetails: "Chế độ Turbo tắt tất cả logic VNC và mã hóa tất cả các khung hình như một bộ mã hóa video truyền thống.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "Mã hóa CPU",
            jpegQualityLabel: "Chất lượng Cơ bản: {jpegQuality}",
            paintOverJpegQualityLabel: "Chất lượng Vẽ đè: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF Cải thiện vùng tĩnh ({crf}):",
            usePaintOverQualityLabel: "Sử dụng Cải thiện vùng tĩnh",
        },
        audio: {
            title: "Cài đặt Âm thanh",
            bitrateLabel: "Tốc độ bit Âm thanh ({bitrate} kbps):",
            inputLabel: "Đầu vào (Micro):",
            outputLabel: "Đầu ra (Loa):",
            outputNotSupported: "Trình duyệt này không hỗ trợ chọn thiết bị đầu ra.",
            deviceErrorDefault: "Lỗi liệt kê thiết bị âm thanh: {errorName}",
            deviceErrorPermission: "Quyền bị từ chối. Vui lòng cho phép truy cập micro trong cài đặt trình duyệt để chọn thiết bị.",
            deviceErrorNotFound: "Không tìm thấy thiết bị âm thanh nào.",
            defaultInputLabelFallback: "Thiết bị Đầu vào {index}",
            defaultOutputLabelFallback: "Thiết bị Đầu ra {index}",
        },
        screen: {
            title: "Cài đặt Màn hình",
            presetLabel: "Cài đặt sẵn:",
            resolutionPresetSelect: "-- Chọn Cài đặt sẵn --",
            widthLabel: "Chiều rộng:",
            heightLabel: "Chiều cao:",
            widthPlaceholder: "ví dụ: 1920",
            heightPlaceholder: "ví dụ: 1080",
            setManualButton: "Đặt Độ phân giải Thủ công",
            resetButton: "Đặt lại về Cửa sổ",
            scaleLocallyLabel: "Co giãn Cục bộ:",
            scaleLocallyOn: "BẬT",
            scaleLocallyOff: "TẮT",
            scaleLocallyTitleEnable: "Bật Co giãn Cục bộ (Giữ Tỷ lệ khung hình)",
            scaleLocallyTitleDisable: "Tắt Co giãn Cục bộ (Sử dụng Độ phân giải Chính xác)",
            uiScalingLabel: "Tỷ lệ Giao diện:",
            hidpiLabel: "HiDPI (Hoàn hảo đến từng Pixel)",
            hidpiEnableTitle: "Bật HiDPI (Hoàn hảo đến từng Pixel)",
            hidpiDisableTitle: "Tắt HiDPI (Sử dụng CSS Scaling)",
            antiAliasingLabel: "Khử răng cưa",
            antiAliasingEnableTitle: "Bật khử răng cưa (làm mịn khi co giãn)",
            antiAliasingDisableTitle: "Tắt khử răng cưa (buộc hiển thị pixel)",
            useNativeCursorStylesLabel: "Sử dụng con trỏ CSS",
            useNativeCursorStylesEnableTitle: "Sử dụng kết xuất con trỏ CSS (Thay thế con trỏ hệ thống)",
            useNativeCursorStylesDisableTitle: "Sử dụng kết xuất con trỏ canvas (Vẽ lên canvas)",
            addScreenTitle: "Thêm màn hình thứ hai",
            addScreenButton: "Thêm Màn hình +",
        },
        stats: {
            title: "Thống kê",
            cpuLabel: "CPU",
            gpuLabel: "Sử dụng GPU",
            sysMemLabel: "Bộ nhớ Hệ thống",
            gpuMemLabel: "Bộ nhớ GPU",
            fpsLabel: "FPS",
            audioLabel: "Âm thanh",
            tooltipCpu: "Sử dụng CPU: {value}%",
            tooltipGpu: "Sử dụng GPU: {value}%",
            tooltipSysMem: "Bộ nhớ Hệ thống: {used} / {total}",
            tooltipGpuMem: "Bộ nhớ GPU: {used} / {total}",
            tooltipFps: "FPS Máy khách: {value}",
            tooltipAudio: "Bộ đệm Âm thanh: {value}",
            tooltipMemoryNA: "Không có",
            bandwidthLabel: "Băng thông",
            tooltipBandwidth: "Băng thông: {value}mbps",
            latencyLabel: "Độ trễ",
            tooltipLatency: "Độ trễ trọn vòng: {value}ms",
        },
        clipboard: {
            title: "Bộ nhớ tạm",
            label: "Bộ nhớ tạm Máy chủ:",
            placeholder: "Nội dung bộ nhớ tạm từ máy chủ...",
            binaryModeLabel: "Hỗ trợ Hình ảnh",
            binaryModeDetails: "Cho phép sao chép và dán hình ảnh đến và từ phiên làm việc từ xa.",
        },
        files: {
            title: "Tệp",
            uploadButton: "Tải lên Tệp",
            uploadButtonTitle: "Tải tệp lên phiên làm việc từ xa",
            downloadButtonTitle: "Tải xuống Tệp",
        },
        gamepads: {
            title: "Tay cầm chơi game",
            noActivity: "Chưa phát hiện hoạt động nào của tay cầm chơi game...",
            touchEnableTitle: "Bật Tay cầm cảm ứng",
            touchDisableTitle: "Tắt Tay cầm cảm ứng",
            touchActiveLabel: "Tay cầm cảm ứng: BẬT",
            touchInactiveLabel: "Tay cầm cảm ứng: TẮT",
            physicalHiddenForTouch: "Màn hình tay cầm vật lý bị ẩn khi tay cầm cảm ứng đang hoạt động.",
            noActivityMobileOrEnableTouch: "Không có tay cầm vật lý. Bật tay cầm cảm ứng hoặc kết nối bộ điều khiển."
        },
        apps: {
          title: "Ứng dụng",
          openButtonTitle: "Quản lý Ứng dụng",
          openButton: "Quản lý Ứng dụng"
        },
        sharing: {
            title: "Chia sẻ"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Máy tính xách tay)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "Đóng modal ứng dụng",
        loading: "Đang tải ứng dụng...",
        errorLoading: "Tải dữ liệu ứng dụng thất bại. Vui lòng thử lại.",
        searchPlaceholder: "Tìm kiếm ứng dụng...",
        noAppsFound: "Không tìm thấy ứng dụng nào khớp với tìm kiếm của bạn.",
        backButton: "Quay lại danh sách",
        installButton: "Cài đặt",
        updateButton: "Cập nhật",
        removeButton: "Gỡ bỏ",
        installingMessage: "Mô phỏng cài đặt cho: {{appName}}",
        removingMessage: "Mô phỏng gỡ bỏ cho: {{appName}}",
        updatingMessage: "Mô phỏng cập nhật cho: {{appName}}",
        installedBadge: "Đã cài đặt"
    },
    notifications: {
        closeButtonAlt: "Đóng thông báo cho {fileName}",
        uploading: "Đang tải lên... {progress}%",
        uploadComplete: "Tải lên Hoàn tất",
        uploadFailed: "Tải lên Thất bại",
        errorPrefix: "Lỗi:",
        unknownError: "Đã xảy ra lỗi không xác định.",
        copiedTitle: "Đã sao chép: {label}",
        copiedMessage: "Đã sao chép liên kết vào bộ nhớ tạm: {textToCopy}",
        copyFailedTitle: "Sao chép Thất bại: {label}",
        copyFailedError: "Không thể sao chép liên kết vào bộ nhớ tạm.",
        scalingTitle: "Đã cập nhật tỷ lệ: Cần hành động",
        scalingMessage: "Đã áp dụng tỷ lệ mới. Một số ứng dụng hoặc môi trường máy tính để bàn có thể yêu cầu khởi động lại.",
    },
    alerts: {
        invalidResolution: "Vui lòng nhập số nguyên dương hợp lệ cho Chiều rộng và Chiều cao.",
    },
    byteUnits: ['Byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Byte",
    filesModal: {
        closeAlt: "Đóng modal tệp",
        iframeTitle: "Tệp có thể tải xuống"
    }
};

// --- Thai Translations ---
const th = {
    selkiesLogoAlt: "โลโก้ Selkies",
    toggleThemeTitle: "สลับธีม",
    fullscreenTitle: "เข้าสู่โหมดเต็มหน้าจอ",
    gamingModeTitle: "โหมดเกมมิ่ง",
    trackpadModeTitle: "โหมดแทร็คแพด",
    buttons: {
        videoStreamEnableTitle: "เปิดใช้งานสตรีมวิดีโอ",
        videoStreamDisableTitle: "ปิดใช้งานสตรีมวิดีโอ",
        audioStreamEnableTitle: "เปิดใช้งานสตรีมเสียง",
        audioStreamDisableTitle: "ปิดใช้งานสตรีมเสียง",
        microphoneEnableTitle: "เปิดใช้งานไมโครโฟน",
        microphoneDisableTitle: "ปิดใช้งานไมโครโฟน",
        gamepadEnableTitle: "เปิดใช้งานอินพุตเกมแพด",
        gamepadDisableTitle: "ปิดใช้งานอินพุตเกมแพด",
        virtualKeyboardButtonTitle: "แสดงแป้นพิมพ์",
        h264FullColorEnableTitle: "เปิดใช้งาน H.264 สีสมบูรณ์",
        h264FullColorDisableTitle: "ปิดใช้งาน H.264 สีสมบูรณ์",
        h264StreamingModeDisableTitle: "ปิดใช้งานเทอร์โบ",
        h264StreamingModeEnableTitle: "เปิดใช้งานเทอร์โบ",
        useCpuEnableTitle: "เปิดใช้งานการเข้ารหัส CPU แบบบังคับ (เขียนทับ nvenc/vaapi)",
        useCpuDisableTitle: "ปิดใช้งานการเข้ารหัส CPU แบบบังคับ (เขียนทับ nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "เปิดใช้งานการปรับปรุงพื้นที่นิ่ง (ทำความสะอาดส่วนที่หยุดนิ่งของหน้าจอ)",
        usePaintOverQualityDisableTitle: "ปิดใช้งานการปรับปรุงพื้นที่นิ่ง (ทำความสะอาดส่วนที่หยุดนิ่งของหน้าจอ)",
        binaryClipboardEnableTitle: "เปิดใช้งานคลิปบอร์ดรูปภาพ",
        binaryClipboardDisableTitle: "ปิดใช้งานคลิปบอร์ดรูปภาพ",
    },
    sections: {
        video: {
            title: "การตั้งค่าวิดีโอ",
            encoderLabel: "ตัวเข้ารหัส:",
            framerateLabel: "เฟรมต่อวินาที ({framerate} FPS):",
            bitrateLabel: "บิตเรตวิดีโอ ({bitrate} Mbps):",
            bufferLabelImmediate: "ขนาดบัฟเฟอร์วิดีโอ (0 (ทันที)):",
            bufferLabelFrames: "ขนาดบัฟเฟอร์วิดีโอ ({videoBufferSize} เฟรม):",
            crfLabel: "วิดีโอ CRF ({crf}):",
            fullColorLabel: "สีสมบูรณ์ 4:4:4",
            streamingModeDetails: "โหมดเทอร์โบจะปิดการทำงานของ VNC ทั้งหมดและเข้ารหัสเฟรมทั้งหมดเหมือนตัวเข้ารหัสวิดีโอแบบดั้งเดิม",
            streamingModeLabel: "เทอร์โบ",
            useCpuLabel: "การเข้ารหัส CPU",
            jpegQualityLabel: "คุณภาพพื้นฐาน: {jpegQuality}",
            paintOverJpegQualityLabel: "คุณภาพการวาดทับ: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF การปรับปรุงพื้นที่นิ่ง ({crf}):",
            usePaintOverQualityLabel: "ใช้การปรับปรุงพื้นที่นิ่ง",
        },
        audio: {
            title: "การตั้งค่าเสียง",
            bitrateLabel: "บิตเรตเสียง ({bitrate} kbps):",
            inputLabel: "อินพุต (ไมโครโฟน):",
            outputLabel: "เอาต์พุต (ลำโพง):",
            outputNotSupported: "เบราว์เซอร์นี้ไม่รองรับการเลือกอุปกรณ์เอาต์พุต",
            deviceErrorDefault: "ข้อผิดพลาดในการแสดงรายการอุปกรณ์เสียง: {errorName}",
            deviceErrorPermission: "การอนุญาตถูกปฏิเสธ โปรดอนุญาตการเข้าถึงไมโครโฟนในการตั้งค่าเบราว์เซอร์เพื่อเลือกอุปกรณ์",
            deviceErrorNotFound: "ไม่พบอุปกรณ์เสียง",
            defaultInputLabelFallback: "อุปกรณ์อินพุต {index}",
            defaultOutputLabelFallback: "อุปกรณ์เอาต์พุต {index}",
        },
        screen: {
            title: "การตั้งค่าหน้าจอ",
            presetLabel: "ค่าที่ตั้งไว้ล่วงหน้า:",
            resolutionPresetSelect: "-- เลือกค่าที่ตั้งไว้ --",
            widthLabel: "ความกว้าง:",
            heightLabel: "ความสูง:",
            widthPlaceholder: "เช่น 1920",
            heightPlaceholder: "เช่น 1080",
            setManualButton: "ตั้งค่าความละเอียดด้วยตนเอง",
            resetButton: "รีเซ็ตเป็นหน้าต่าง",
            scaleLocallyLabel: "ปรับขนาดในเครื่อง:",
            scaleLocallyOn: "เปิด",
            scaleLocallyOff: "ปิด",
            scaleLocallyTitleEnable: "เปิดใช้งานการปรับขนาดในเครื่อง (รักษาสัดส่วนภาพ)",
            scaleLocallyTitleDisable: "ปิดใช้งานการปรับขนาดในเครื่อง (ใช้ความละเอียดที่แน่นอน)",
            uiScalingLabel: "การปรับขนาด UI:",
            hidpiLabel: "HiDPI (ความคมชัดระดับพิกเซล)",
            hidpiEnableTitle: "เปิดใช้งาน HiDPI (ความคมชัดระดับพิกเซล)",
            hidpiDisableTitle: "ปิดใช้งาน HiDPI (ใช้การปรับขนาด CSS)",
            antiAliasingLabel: "การลบรอยหยัก",
            antiAliasingEnableTitle: "เปิดใช้งานการลบรอยหยัก (ปรับให้เรียบเมื่อปรับขนาด)",
            antiAliasingDisableTitle: "ปิดใช้งานการลบรอยหยัก (บังคับให้เป็นพิกเซล)",
            useNativeCursorStylesLabel: "ใช้เคอร์เซอร์แบบ CSS",
            useNativeCursorStylesEnableTitle: "ใช้การแสดงผลเคอร์เซอร์แบบ CSS (แทนที่เคอร์เซอร์ของระบบ)",
            useNativeCursorStylesDisableTitle: "ใช้การแสดงผลเคอร์เซอร์บนแคนวาส (วาดลงบนแคนวาส)",
            addScreenTitle: "เพิ่มหน้าจอที่สอง",
            addScreenButton: "เพิ่มหน้าจอ +",
        },
        stats: {
            title: "สถิติ",
            cpuLabel: "CPU",
            gpuLabel: "การใช้งาน GPU",
            sysMemLabel: "หน่วยความจำระบบ",
            gpuMemLabel: "หน่วยความจำ GPU",
            fpsLabel: "FPS",
            audioLabel: "เสียง",
            tooltipCpu: "การใช้งาน CPU: {value}%",
            tooltipGpu: "การใช้งาน GPU: {value}%",
            tooltipSysMem: "หน่วยความจำระบบ: {used} / {total}",
            tooltipGpuMem: "หน่วยความจำ GPU: {used} / {total}",
            tooltipFps: "FPS ไคลเอ็นต์: {value}",
            tooltipAudio: "บัฟเฟอร์เสียง: {value}",
            tooltipMemoryNA: "ไม่มีข้อมูล",
            bandwidthLabel: "แบนด์วิดท์",
            tooltipBandwidth: "แบนด์วิดท์: {value}mbps",
            latencyLabel: "ความหน่วง",
            tooltipLatency: "ความหน่วงไป-กลับ: {value}ms",
        },
        clipboard: {
            title: "คลิปบอร์ด",
            label: "คลิปบอร์ดเซิร์ฟเวอร์:",
            placeholder: "เนื้อหาคลิปบอร์ดจากเซิร์ฟเวอร์...",
            binaryModeLabel: "รองรับรูปภาพ",
            binaryModeDetails: "อนุญาตให้คัดลอกและวางรูปภาพไปยังและจากเซสชันระยะไกล",
        },
        files: {
            title: "ไฟล์",
            uploadButton: "อัปโหลดไฟล์",
            uploadButtonTitle: "อัปโหลดไฟล์ไปยังเซสชันระยะไกล",
            downloadButtonTitle: "ดาวน์โหลดไฟล์",
        },
        gamepads: {
            title: "เกมแพด",
            noActivity: "ยังไม่พบกิจกรรมของเกมแพด...",
            touchEnableTitle: "เปิดใช้งานทัชเกมแพด",
            touchDisableTitle: "ปิดใช้งานทัชเกมแพด",
            touchActiveLabel: "ทัชเกมแพด: เปิด",
            touchInactiveLabel: "ทัชเกมแพด: ปิด",
            physicalHiddenForTouch: "การแสดงผลเกมแพดจริงจะถูกซ่อนขณะที่ทัชเกมแพดทำงานอยู่",
            noActivityMobileOrEnableTouch: "ไม่มีเกมแพดจริง เปิดใช้งานทัชเกมแพดหรือเชื่อมต่อคอนโทรลเลอร์"
        },
        apps: {
          title: "แอป",
          openButtonTitle: "จัดการแอป",
          openButton: "จัดการแอป"
        },
        sharing: {
            title: "การแชร์"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (แล็ปท็อป)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: { // New section for "AppsModal"
        closeAlt: "ปิดหน้าต่างแอป",
        loading: "กำลังโหลดแอป...",
        errorLoading: "โหลดข้อมูลแอปไม่สำเร็จ โปรดลองอีกครั้ง",
        searchPlaceholder: "ค้นหาแอป...",
        noAppsFound: "ไม่พบแอปที่ตรงกับการค้นหาของคุณ",
        backButton: "กลับไปที่รายการ",
        installButton: "ติดตั้ง",
        updateButton: "อัปเดต",
        removeButton: "ลบ",
        installingMessage: "กำลังจำลองการติดตั้งสำหรับ: {{appName}}",
        removingMessage: "กำลังจำลองการลบสำหรับ: {{appName}}",
        updatingMessage: "กำลังจำลองการอัปเดตสำหรับ: {{appName}}",
        installedBadge: "ติดตั้งแล้ว"
    },
    notifications: {
        closeButtonAlt: "ปิดการแจ้งเตือนสำหรับ {fileName}",
        uploading: "กำลังอัปโหลด... {progress}%",
        uploadComplete: "อัปโหลดเสร็จสมบูรณ์",
        uploadFailed: "การอัปโหลดล้มเหลว",
        errorPrefix: "ข้อผิดพลาด:",
        unknownError: "เกิดข้อผิดพลาดที่ไม่รู้จัก",
        copiedTitle: "คัดลอกแล้ว: {label}",
        copiedMessage: "คัดลอกลิงก์ไปยังคลิปบอร์ดแล้ว: {textToCopy}",
        copyFailedTitle: "การคัดลอกล้มเหลว: {label}",
        copyFailedError: "ไม่สามารถคัดลอกลิงก์ไปยังคลิปบอร์ดได้",
        scalingTitle: "ปรับขนาดแล้ว: ต้องการการดำเนินการ",
        scalingMessage: "ใช้การปรับขนาดใหม่แล้ว แอปพลิเคชันหรือสภาพแวดล้อมเดสก์ท็อปบางอย่างอาจต้องรีสตาร์ท",
    },
    alerts: {
        invalidResolution: "โปรดป้อนจำนวนเต็มบวกที่ถูกต้องสำหรับความกว้างและความสูง",
    },
    byteUnits: ['ไบต์', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 ไบต์",
    filesModal: {
        closeAlt: "ปิดหน้าต่างไฟล์",
        iframeTitle: "ไฟล์ที่สามารถดาวน์โหลดได้"
    }
};

// --- Filipino Translations ---
const fil = {
    selkiesLogoAlt: "Logo ng Selkies",
    toggleThemeTitle: "I-toggle ang Tema",
    fullscreenTitle: "Pumasok sa Fullscreen",
    gamingModeTitle: "Gaming Mode",
    trackpadModeTitle: "Modo ng Trackpad",
    buttons: {
        videoStreamEnableTitle: "Paganahin ang Video Stream",
        videoStreamDisableTitle: "Huwag paganahin ang Video Stream",
        audioStreamEnableTitle: "Paganahin ang Audio Stream",
        audioStreamDisableTitle: "Huwag paganahin ang Audio Stream",
        microphoneEnableTitle: "Paganahin ang Mikropono",
        microphoneDisableTitle: "Huwag paganahin ang Mikropono",
        gamepadEnableTitle: "Paganahin ang Gamepad Input",
        gamepadDisableTitle: "Huwag paganahin ang Gamepad Input",
        virtualKeyboardButtonTitle: "Ipakita ang Keyboard",
        h264FullColorEnableTitle: "Paganahin ang H.264 Buong Kulay",
        h264FullColorDisableTitle: "Huwag paganahin ang H.264 Buong Kulay",
        h264StreamingModeDisableTitle: "Huwag paganahin ang Turbo",
        h264StreamingModeEnableTitle: "Paganahin ang Turbo",
        useCpuEnableTitle: "Paganahin ang Puwersahang CPU Encoding (Pinapalitan ang nvenc/vaapi)",
        useCpuDisableTitle: "Huwag paganahin ang Puwersahang CPU Encoding (Pinapalitan ang nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Paganahin ang Paglilinis ng Static (Nililinis ang mga static na bahagi ng screen)",
        usePaintOverQualityDisableTitle: "Huwag paganahin ang Paglilinis ng Static (Nililinis ang mga static na bahagi ng screen)",
        binaryClipboardEnableTitle: "Paganahin ang Clipboard ng Imahe",
        binaryClipboardDisableTitle: "Huwag paganahin ang Clipboard ng Imahe",
    },
    sections: {
        video: {
            title: "Mga Setting ng Video",
            encoderLabel: "Encoder:",
            framerateLabel: "Mga frame bawat segundo ({framerate} FPS):",
            bitrateLabel: "Video Bitrate ({bitrate} Mbps):",
            bufferLabelImmediate: "Laki ng Video Buffer (0 (Agad)):",
            bufferLabelFrames: "Laki ng Video Buffer ({videoBufferSize} frames):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "Buong Kulay 4:4:4",
            streamingModeDetails: "Ang Turbo mode ay hindi pinapagana ang lahat ng lohika ng VNC at ini-encode ang lahat ng mga frame tulad ng isang tradisyonal na video encoder.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU Encoding",
            jpegQualityLabel: "Batayang Kalidad: {jpegQuality}",
            paintOverJpegQualityLabel: "Kalidad ng Paintover: {paintOverJpegQuality}",
            paintoverCrfLabel: "CRF sa Paglilinis ng Static ({crf}):",
            usePaintOverQualityLabel: "Gamitin ang Paglilinis ng Static",
        },
        audio: {
            title: "Mga Setting ng Audio",
            bitrateLabel: "Audio Bitrate ({bitrate} kbps):",
            inputLabel: "Input (Mikropono):",
            outputLabel: "Output (Speaker):",
            outputNotSupported: "Hindi suportado ng browser na ito ang pagpili ng output device.",
            deviceErrorDefault: "Error sa paglista ng mga audio device: {errorName}",
            deviceErrorPermission: "Tinanggihan ang pahintulot. Mangyaring payagan ang access sa mikropono sa mga setting ng browser upang pumili ng mga device.",
            deviceErrorNotFound: "Walang nahanap na mga audio device.",
            defaultInputLabelFallback: "Input Device {index}",
            defaultOutputLabelFallback: "Output Device {index}",
        },
        screen: {
            title: "Mga Setting ng Screen",
            presetLabel: "Preset:",
            resolutionPresetSelect: "-- Pumili ng Preset --",
            widthLabel: "Lapad:",
            heightLabel: "Taas:",
            widthPlaceholder: "hal., 1920",
            heightPlaceholder: "hal., 1080",
            setManualButton: "Itakda ang Manual na Resolusyon",
            resetButton: "I-reset sa Window",
            scaleLocallyLabel: "I-scale Lokal:",
            scaleLocallyOn: "ON",
            scaleLocallyOff: "OFF",
            scaleLocallyTitleEnable: "Paganahin ang Lokal na Pag-scale (Panatilihin ang Aspect Ratio)",
            scaleLocallyTitleDisable: "Huwag paganahin ang Lokal na Pag-scale (Gamitin ang Eksaktong Resolusyon)",
            uiScalingLabel: "Pag-scale ng UI:",
            hidpiLabel: "HiDPI (Pixel Perfect)",
            hidpiEnableTitle: "Paganahin ang HiDPI (Pixel Perfect)",
            hidpiDisableTitle: "Huwag paganahin ang HiDPI (Gamitin ang CSS Scaling)",
            antiAliasingLabel: "Anti-aliasing (Pagpapakinis)",
            antiAliasingEnableTitle: "Paganahin ang anti-aliasing (makinis kapag nag-scale)",
            antiAliasingDisableTitle: "Huwag paganahin ang anti-aliasing (puwersahing maging pixelated)",
            useNativeCursorStylesLabel: "Gamitin ang mga CSS cursor",
            useNativeCursorStylesEnableTitle: "Gamitin ang pag-render ng CSS cursor (Palitan ang mga cursor ng system)",
            useNativeCursorStylesDisableTitle: "Gamitin ang pag-render ng canvas cursor (Iguhit sa canvas)",
            addScreenTitle: "Magdagdag ng pangalawang screen",
            addScreenButton: "Magdagdag ng Screen +",
        },
        stats: {
            title: "Stats",
            cpuLabel: "CPU",
            gpuLabel: "Paggamit ng GPU",
            sysMemLabel: "Sys Mem",
            gpuMemLabel: "GPU Mem",
            fpsLabel: "FPS",
            audioLabel: "Audio",
            tooltipCpu: "Paggamit ng CPU: {value}%",
            tooltipGpu: "Paggamit ng GPU: {value}%",
            tooltipSysMem: "Memorya ng System: {used} / {total}",
            tooltipGpuMem: "Memorya ng GPU: {used} / {total}",
            tooltipFps: "Client FPS: {value}",
            tooltipAudio: "Mga Audio Buffer: {value}",
            tooltipMemoryNA: "N/A",
            bandwidthLabel: "Bandwidth",
            tooltipBandwidth: "Bandwidth: {value}mbps",
            latencyLabel: "Latency",
            tooltipLatency: "Round Trip Latency: {value}ms",
        },
        clipboard: {
            title: "Clipboard",
            label: "Server Clipboard:",
            placeholder: "Nilalaman ng clipboard mula sa server...",
            binaryModeLabel: "Suporta sa Imahe",
            binaryModeDetails: "Pinapayagan ang pag-copy at pag-paste ng mga imahe papunta at mula sa remote session.",
        },
        files: {
            title: "Mga File",
            uploadButton: "Mag-upload ng mga File",
            uploadButtonTitle: "Mag-upload ng mga file sa remote session",
            downloadButtonTitle: "I-download ang mga File",
        },
        gamepads: {
            title: "Mga Gamepad",
            noActivity: "Wala pang aktibidad ng gamepad na natukoy...",
            touchEnableTitle: "Paganahin ang Touch Gamepad",
            touchDisableTitle: "Huwag paganahin ang Touch Gamepad",
            touchActiveLabel: "Touch Gamepad: ON",
            touchInactiveLabel: "Touch Gamepad: OFF",
            physicalHiddenForTouch: "Nakatago ang display ng pisikal na gamepad habang aktibo ang touch gamepad.",
            noActivityMobileOrEnableTouch: "Walang pisikal na gamepad. Paganahin ang touch gamepad o kumonekta ng controller."
        },
        apps: {
          title: "Mga App",
          openButtonTitle: "Pamahalaan ang mga App",
          openButton: "Pamahalaan ang mga App"
        },
        sharing: {
            title: "Pagbabahagi"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Laptop)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: {
        closeAlt: "Isara ang modal ng mga app",
        loading: "Nilo-load ang mga app...",
        errorLoading: "Nabigo ang pag-load ng data ng app. Pakisubukang muli.",
        searchPlaceholder: "Maghanap ng mga app...",
        noAppsFound: "Walang nahanap na app na tumutugma sa iyong paghahanap.",
        backButton: "Bumalik sa listahan",
        installButton: "I-install",
        updateButton: "I-update",
        removeButton: "Alisin",
        installingMessage: "Sinusubukan ang pag-install para sa: {{appName}}",
        removingMessage: "Sinusubukan ang pag-alis para sa: {{appName}}",
        updatingMessage: "Sinusubukan ang pag-update para sa: {{appName}}",
        installedBadge: "Naka-install"
    },
    notifications: {
        closeButtonAlt: "Isara ang notification para sa {fileName}",
        uploading: "Nag-a-upload... {progress}%",
        uploadComplete: "Kumpleto ang Pag-upload",
        uploadFailed: "Nabigo ang Pag-upload",
        errorPrefix: "Error:",
        unknownError: "May naganap na hindi kilalang error.",
        copiedTitle: "Kinopya: {label}",
        copiedMessage: "Nakopya ang link sa clipboard: {textToCopy}",
        copyFailedTitle: "Nabigo ang Pagkopya: {label}",
        copyFailedError: "Hindi makopya ang link sa clipboard.",
        scalingTitle: "Na-update ang Pag-scale: Kinakailangan ang Aksyon",
        scalingMessage: "Inilapat ang bagong pag-scale. Maaaring kailanganin ng ilang application o desktop environment na mag-restart.",
    },
    alerts: {
        invalidResolution: "Mangyaring maglagay ng mga wastong positibong integer para sa Lapad at Taas.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Isara ang modal ng mga file",
        iframeTitle: "Mga Nada-download na File"
    }
};

// --- Danish Translations ---
const da = {
    selkiesLogoAlt: "Selkies Logo",
    toggleThemeTitle: "Skift tema",
    fullscreenTitle: "Start Fuldskærm",
    gamingModeTitle: "Spiltilstand",
    trackpadModeTitle: "Trackpad-tilstand",
    buttons: {
        videoStreamEnableTitle: "Aktiver videostream",
        videoStreamDisableTitle: "Deaktiver videostream",
        audioStreamEnableTitle: "Aktiver lydstream",
        audioStreamDisableTitle: "Deaktiver lydstream",
        microphoneEnableTitle: "Aktiver mikrofon",
        microphoneDisableTitle: "Deaktiver mikrofon",
        gamepadEnableTitle: "Aktiver Gamepad-input",
        gamepadDisableTitle: "Deaktiver Gamepad-input",
        virtualKeyboardButtonTitle: "Vis tastatur",
        h264FullColorEnableTitle: "Paganahin ang H.264 Buong Kulay",
        h264FullColorDisableTitle: "Huwag paganahin ang H.264 Buong Kulay",
        h264StreamingModeDisableTitle: "Deaktiver Turbo",
        h264StreamingModeEnableTitle: "Aktiver Turbo",
        useCpuEnableTitle: "Aktiver Tvungen CPU-kodning (Tilsidesætter nvenc/vaapi)",
        useCpuDisableTitle: "Deaktiver Tvungen CPU-kodning (Tilsidesætter nvenc/vaapi)",
        usePaintOverQualityEnableTitle: "Aktiver Statisk Forbedring (Rydder op i statiske dele af skærmen)",
        usePaintOverQualityDisableTitle: "Deaktiver Statisk Forbedring (Rydder op i statiske dele af skærmen)",
        binaryClipboardEnableTitle: "Aktiver billedudklipsholder",
        binaryClipboardDisableTitle: "Deaktiver billedudklipsholder",
    },
    sections: {
        video: {
            title: "Videoindstillinger",
            encoderLabel: "Encoder:",
            framerateLabel: "Billeder pr. sekund ({framerate} FPS):",
            bitrateLabel: "Video Bitrate ({bitrate} Mbps):",
            bufferLabelImmediate: "Videobufferstørrelse (0 (Øjeblikkelig)):",
            bufferLabelFrames: "Videobufferstørrelse ({videoBufferSize} billeder):",
            crfLabel: "Video CRF ({crf}):",
            fullColorLabel: "Fuld Farve 4:4:4",
            streamingModeDetails: "Turbo-tilstand deaktiverer al VNC-logik og koder alle billeder som en traditionel video-encoder.",
            streamingModeLabel: "Turbo",
            useCpuLabel: "CPU-kodning",
            jpegQualityLabel: "Grundkvalitet: {jpegQuality}",
            paintOverJpegQualityLabel: "Overmalingskvalitet: {paintOverJpegQuality}",
            paintoverCrfLabel: "Statisk Forbedring CRF ({crf}):",
            usePaintOverQualityLabel: "Brug Statisk Forbedring",
        },
        audio: {
            title: "Lydindstillinger",
            bitrateLabel: "Lyd bitrate ({bitrate} kbps):",
            inputLabel: "Input (Mikrofon):",
            outputLabel: "Output (Højttaler):",
            outputNotSupported: "Valg af outputenhed understøttes ikke af denne browser.",
            deviceErrorDefault: "Fejl ved visning af lydenheder: {errorName}",
            deviceErrorPermission: "Adgang nægtet. Tillad venligst mikrofonadgang i browserindstillinger for at vælge enheder.",
            deviceErrorNotFound: "Ingen lydenheder fundet.",
            defaultInputLabelFallback: "Inputenhed {index}",
            defaultOutputLabelFallback: "Outputenhed {index}",
        },
        screen: {
            title: "Skærmindstillinger",
            presetLabel: "Forudindstilling:",
            resolutionPresetSelect: "-- Vælg forudindstilling --",
            widthLabel: "Bredde:",
            heightLabel: "Højde:",
            widthPlaceholder: "f.eks. 1920",
            heightPlaceholder: "f.eks. 1080",
            setManualButton: "Indstil opløsning manuelt",
            resetButton: "Nulstil til Vindue",
            scaleLocallyLabel: "Skaler lokalt:",
            scaleLocallyOn: "TIL",
            scaleLocallyOff: "FRA",
            scaleLocallyTitleEnable: "Aktiver lokal skalering (Bevar aspektforhold)",
            scaleLocallyTitleDisable: "Deaktiver lokal skalering (Brug præcis opløsning)",
            uiScalingLabel: "UI-skalering:",
            hidpiLabel: "HiDPI (Pixel Perfekt)",
            hidpiEnableTitle: "Aktivér HiDPI (Pixel Perfekt)",
            hidpiDisableTitle: "Deaktivér HiDPI (Brug CSS-skalering)",
            antiAliasingLabel: "Kantudjævning",
            antiAliasingEnableTitle: "Aktiver kantudjævning (glat ved skalering)",
            antiAliasingDisableTitle: "Deaktiver kantudjævning (tving pixeleret)",
            useNativeCursorStylesLabel: "Brug CSS-markører",
            useNativeCursorStylesEnableTitle: "Brug CSS-markørgengivelse (Erstatter systemmarkører)",
            useNativeCursorStylesDisableTitle: "Brug lærredsmarkørgengivelse (Tegn på lærred)",
            addScreenTitle: "Tilføj en anden skærm",
            addScreenButton: "Tilføj Skærm +",
        },
        stats: {
            title: "Statistik",
            cpuLabel: "CPU",
            gpuLabel: "GPU",
            sysMemLabel: "Systemhuk.",
            gpuMemLabel: "GPU-huk.",
            fpsLabel: "FPS",
            audioLabel: "Lyd",
            tooltipCpu: "CPU-brug: {value}%",
            tooltipGpu: "GPU-brug: {value}%",
            tooltipSysMem: "Systemhukommelse: {used} / {total}",
            tooltipGpuMem: "GPU-hukommelse: {used} / {total}",
            tooltipFps: "Klient FPS: {value}",
            tooltipAudio: "Lydbuffere: {value}",
            tooltipMemoryNA: "Utilgængelig",
            bandwidthLabel: "Båndbredde",
            tooltipBandwidth: "Båndbredde: {value}mbps",
            latencyLabel: "Forsinkelse",
            tooltipLatency: "Tur-retur forsinkelse: {value}ms",
        },
        clipboard: {
            title: "Udklipsholder",
            label: "Server Udklipsholder:",
            placeholder: "Indhold fra serverens udklipsholder...",
            binaryModeLabel: "Billedstøtte",
            binaryModeDetails: "Tillader kopiering og indsættelse af billeder til og fra den eksterne session.",
        },
        files: {
            title: "Filer",
            uploadButton: "Upload Filer",
            uploadButtonTitle: "Upload filer til den eksterne session",
            downloadButtonTitle: "Download Filer",
        },
        gamepads: {
            title: "Gamepads",
            noActivity: "Ingen fysisk gamepad-aktivitet registreret endnu...",
            touchEnableTitle: "Aktiver Touch Gamepad",
            touchDisableTitle: "Deaktiver Touch Gamepad",
            touchActiveLabel: "Touch Gamepad: TIL",
            touchInactiveLabel: "Touch Gamepad: FRA",
            physicalHiddenForTouch: "Visning af fysisk gamepad er skjult, mens touch gamepad er aktiv.",
            noActivityMobileOrEnableTouch: "Ingen fysiske gamepads. Aktiver touch gamepad eller tilslut en controller."
        },
        apps: {
          title: "Apps",
          openButtonTitle: "Administrer Apps",
          openButton: "Administrer Apps"
        },
        sharing: {
            title: "Deling"
        }
    },
    resolutionPresets: {
        "1920x1080": "1920 x 1080 (FHD)",
        "1280x720": "1280 x 720 (HD)",
        "1366x768": "1366 x 768 (Bærbar)",
        "1920x1200": "1920 x 1200 (16:10)",
        "2560x1440": "2560 x 1440 (QHD)",
        "3840x2160": "3840 x 2160 (4K UHD)",
        "1024x768": "1024 x 768 (XGA 4:3)",
        "800x600": "800 x 600 (SVGA 4:3)",
        "640x480": "640 x 480 (VGA 4:3)",
        "320x240": "320 x 240 (QVGA 4:3)",
    },
    appsModal: {
        closeAlt: "Luk app-modal",
        loading: "Indlæser apps...",
        errorLoading: "Kunne ikke indlæse app-data. Prøv venligst igen.",
        searchPlaceholder: "Søg efter apps...",
        noAppsFound: "Ingen apps fundet, der matcher din søgning.",
        backButton: "Tilbage til listen",
        installButton: "Installer",
        updateButton: "Opdater",
        removeButton: "Fjern",
        installingMessage: "Simulerer installation for: {{appName}}",
        removingMessage: "Simulerer fjernelse for: {{appName}}",
        updatingMessage: "Simulerer opdatering for: {{appName}}",
        installedBadge: "Installeret"
    },
    notifications: {
        closeButtonAlt: "Luk notifikation for {fileName}",
        uploading: "Uploader... {progress}%",
        uploadComplete: "Upload Fuldført",
        uploadFailed: "Upload Mislykkedes",
        errorPrefix: "Fejl:",
        unknownError: "Der opstod en ukendt fejl.",
        copiedTitle: "Kopieret: {label}",
        copiedMessage: "Link kopieret til udklipsholder: {textToCopy}",
        copyFailedTitle: "Kopiering Mislykkedes: {label}",
        copyFailedError: "Kunne ikke kopiere link til udklipsholder.",
        scalingTitle: "Skalering Opdateret: Handling Påkrævet",
        scalingMessage: "Ny skalering anvendt. Nogle applikationer eller skrivebordsmiljøer kræver muligvis en genstart.",
    },
    alerts: {
        invalidResolution: "Indtast venligst gyldige positive heltal for Bredde og Højde.",
    },
    byteUnits: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
    zeroBytes: "0 Bytes",
    filesModal: {
        closeAlt: "Luk fil-modal",
        iframeTitle: "Downloadbare Filer"
    }
};

// --- Combined Translations Object ---
const translations = {
    en,
    es,
    zh,
    hi,
    pt,
    fr,
    ru,
    de,
    tr,
    it,
    nl,
    ar,
    ko,
    ja,
    vi,
    th,
    fil,
    da,
};

// Function to get translations based on language code
// Falls back to 'en' if the language or specific key is missing
export const getTranslator = (langCode = 'en') => {
    const baseLang = langCode.split('-')[0].toLowerCase(); // Get 'en' from 'en-US'
    // Use the specific language dictionary if available, otherwise default to English
    const langDict = translations[baseLang] || translations.en;
    // Always use English as the ultimate fallback if a key is missing even in the selected language
    const fallbackDict = translations.en;

    // The actual translation function
    const t = (key, variables) => {
        const keys = key.split('.');
        let text = langDict;
        let fallbackText = fallbackDict;
        let keyFoundInLang = true; // Check if found in the selected language

        // Traverse the nested objects for the selected language
        for (const k of keys) {
            if (text && typeof text === 'object' && text.hasOwnProperty(k)) {
                text = text[k];
            } else {
                text = null; // Key not found in selected language
                keyFoundInLang = false;
                break;
            }
        }

        // If not found in the selected language (or value is null), try the English fallback
        if (!keyFoundInLang || text === null) {
            let keyFoundInFallback = true;
             for (const k of keys) {
                if (fallbackText && typeof fallbackText === 'object' && fallbackText.hasOwnProperty(k)) {
                    fallbackText = fallbackText[k];
                } else {
                    fallbackText = null; // Key also not found in fallback
                    keyFoundInFallback = false;
                    break;
                }
            }
            // Use fallback text only if it was actually found
            if (keyFoundInFallback && fallbackText !== null) {
                text = fallbackText;
            } else {
                // If not found in either, keep text as null to return the key below
                text = null;
            }
        }

        // If we found a string value in either language or fallback
        if (typeof text === 'string') {
            return simpleInterpolate(text, variables);
        }

        // If key wasn't found anywhere or isn't a string, return the key itself as an indicator
        console.warn(`Translation key not found or invalid: ${key}`);
        return key;
    };

    // Also return the raw dictionary of the selected language (or fallback)
    const raw = langDict;

    return { t, raw };
};
